Questions about OnPhotonSerializeView() and RPC

Options
Hi,

I am really new to PUN and Network coding. I have read many documents and looking through all the demo examples...
But still have problems when developing my own dodge ball game.
I have attached PhotonView to every spawned character and the ball (which is already in the scene). And I put PhotonTransformView under observed.
So far, the game works fine, clients can see each other move around. But I start getting problem with how picking up the ball.

I am gonna to list my question one by one. Feel free to answer them by question number. Thanks!!

1) I want the character be able to pick up the ball while touching it. Thus, I call a PUNRPC function on the ball. However, when I tried to pass the collider character (Character is my custom class) via PUNRPC. It failed to serialize. I know we can register our own custom type for serialization. However, I wonder if this is the best way to do it since there are lots of variables in Character class. Should I pass this class over network frequently? If not, what will be the best way to pickup stuff (attach the ball on that character)?

2) When should I use PUNRPC and when should I use OnPhotonSerializeView() ? I am a bit confused here. For example, when a shooting ball hit one character, I want to apply damage to the character. What's the best approach here? Call PUNRPC on the collider character's local player so it can replicates to other clients?

3) When working on OnPhotonSerializeView(), if I want to send out custom type, I need to register it like the way we do on PUNRPC?


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

Comments

  • MuMuDaDa
    Options
    To clarify my first question (1), how do I set the ball holder when a character touch the ball?

    Sorry for the confusion...