It appears to be a straight forward question but can RPC functions affect variables outside the RPC function?
Everything works fine on the computer that first sends out the RPC.
I’ve read countless networking tutorials and all of the docs pertaining to this but I feel as if I’ve missed something important. I have an RPC function that is .All and it will instantiate the item I want and apply the correct force on all machines plus the Debug.Log in the RPC gets displayed fine but it will not affect a counter variable I have, except in that specific RPC function.
I have “if (counter > 0)” in my FixedUpdate that I’m attempting to use. In the RPC function I have a counter++ that actually increases the counter(debug.log proves this), but when it checks it in the FixedUpdate, it is back to it’s original 0. What appears to be even stranger is that the next time I call the RPC function, the counter get’s raised and the Debug.Log reflects this, so the second time through the function it shows that the counter is now 2, but just like before, in the FixedUpdate, the counter is 0 again. What is going on?
Thank you for your time.
Counter is declared at the top of the script above all classes. Besides that, these are all the times that counter appears in the script.
The RPC function is called within flingPoo() if certain variables are set to true. I recently took out all non counter code to make it more condensed for easy viewing. Same errors on my end.
Pertinent code:
networkView.RPC(“Fire2”, RPCMode.All, transform.position, power, angle);
@RPC
function Fire2(position1: Vector3, power1: float, angle1: float)
{
counter++;
Debug.Log("c " + counter);
}
function FixedUpdate()
{
Debug.Log("counter " + counter);
FlingPoo();
}