Question about PUNRPC...


I am working on a dodgeball game. Here is the setup:
- I got PhotonView attached to the ball (already in the scene) and observed its transform.
- All the Character have PhotonView attached. However, each character has different abilities (shoot, catch, dodge). All the abilities are prefabs (GameObject attached with a ability component script). Should I PhotonNetworking.Instantiate them? then attach to the character? Or? What's the best way to work on the ability system with network?
- When a local player activate an ability, the ability script starts to apply change on the ball (like change its current parent and apply velocity to its rigidbody). I am so confused how and when should I use RPC and on where (ability or the ball)?

Sorry for all these noob questions. I am still learning the tool. I will be really appreciate with any help!!

Best Answer


  • Thanks for the reply!!!

    I tried using GameObject.Instantiate to spawn the ability object and set its transform parent to the character. Other clients won't see the ability. Do I have to RPC this on other clients? It seems I have 2 options here:
    1) When character's owner call ability init function, it calls RPC for all other clients to GameObject.Instantiate the ability and attach to the character.

    2) Give each ability PhotonView component and PhotonNetwork.instantiate them by character's owner.

    I am not sure which way is better?

    Also, according to your "RPCs should be between those characters and you can delegate to their Skills", could you give me a quick example how this work? I already read through Photon Events document but still have no idea how you make this work with skill system.

    I really appreciate your help :)
Sign In or Register to comment.