Sending RPC function properly
hello , so i have an Gamelogic script in my game scene with photonview attached to it and it handles all the game logic . i am trying to send data using RPC . my question is how can i recieve data from master client from non master client
Example : i am calling this function on master client PhotonView.RPC("RPC_SetPlayerPositions", PhotonTargets.MasterClient); and i am setting certian values in this .but the data i am setting is showing null on non master side
Example : i am calling this function on master client PhotonView.RPC("RPC_SetPlayerPositions", PhotonTargets.MasterClient); and i am setting certian values in this .but the data i am setting is showing null on non master side
0
Best Answer
-
Hi @Romin,
what kind of data do you actually send? The code snippet above doesn't give any hints about this. From the function's name I would assume that it's one or more Vector3 objects, isn't it? However if it's a custom type you need to implement serialize and deserialize functions to be able to send those values across the network.
A further question: why does the MasterClient raises an event that has himself as the only receiver? Maybe in this case it makes more sense to just have a local function call, doesn't it?
You can read about how RPCs are working with additional parameters here. There is a simple sample at the top of the page. If you have a Custom Type you should take a look at this page to see how you can support the new type.5
Answers
-
Hi @Romin,
what kind of data do you actually send? The code snippet above doesn't give any hints about this. From the function's name I would assume that it's one or more Vector3 objects, isn't it? However if it's a custom type you need to implement serialize and deserialize functions to be able to send those values across the network.
A further question: why does the MasterClient raises an event that has himself as the only receiver? Maybe in this case it makes more sense to just have a local function call, doesn't it?
You can read about how RPCs are working with additional parameters here. There is a simple sample at the top of the page. If you have a Custom Type you should take a look at this page to see how you can support the new type.5