Hey guys im trying to understand Unitys built in networking via the old M2H Networking Tutorial Example 4 which is a FPS multiplayer example. I feel that i know the flow of the code. However the following code is kind of throwing me off:
Code from the Pickup Script
And here is the code on the playerscript
now my question lies in the playersNetworkView.RPC("setHP",RPCMode.All, newHP); line of code.
Since it is using RPCMode.All doesnt that mean each playerscript will update their health when one player picks up the pickup? or does the reference to that players network view mean it will only execute the function on that player?
If someone could be so kind as to explain to me how this works i would greatly appreciate it as i was feeling confident with how RPC works until this =P
Thank you for your time and any additional info that may be needed i will post if requested, again this is from example 4 of the M2H Networking Tutorial.
asked Feb 09 '11 at 02:05 AM
What's happening is when this particular player picks up a health pickup, he needs to send a message to all other players that his health increased (hence the RPCMode.All).
The NetworkView part is what is specifying what object to call the function on across the network. It's not calling it on all objects that have this function, its only calling it on all instances of this particular object across the network.
answered Feb 09 '11 at 02:57 AM