How to use an RPC to send an animation over the network?

I am working on a 2player (1v1) game, online thanks to Unity’s native networking code and want to play an animation on a character for BOTH the host and the joiner. I searched around a little and read that I need to do it normally for the host, then use an RPC to send the updated info (saying to play the animation) to the joiner. However I didn’t find any posts actually walking someone through this, and I do not know how to utilize RPCs yet.

Do I need any specific component on my main game object that holds all the scripts, is it just a simple line of code, or what?

1) it doesn't matter in this case, you may even set the synchronisation to off. All you need is a networkView on the object that is using RPCs 2) never done that our came across that, but I have two guesses: - send an RPC that starts a coroutine on the other client, so they work on both sides independently. Probably feasible if they produce consistent results, but some desynchronisation may occur. - have the side running the coroutine send state updates via RPC to the other client. Though if it's about facing direction, isn't it an option to just synchronise the transform using networkView?

2 Answers

2

Have you read the RPC Manual?
Since you can’t just send an animation, so you will either need to pass it’s name or some other value that will trigger a state change in the remote client (depends really on the setup in your game)

You don’t have to send any animation over network. It always play locally on any device.
You have to communicate over all devices that it is a time to start playing animation.

You have to use RPC for this purpose only. So no jittering generates at all for your game.