- Home /
Make an animation play over RPC call?
How would I do this, since RPCs cant do animations right? I've looked into it and cant find anything. Thanks in advance
Answer by jrjr · May 20, 2015 at 11:56 PM
You could send the commands as enum,strings, or a custom codec depending what kind of network solution you are using.
By custom codec this would be something like an int or string that you parse out later. Example in pseudo code: int mycustomcodec (any number between say 1 and 10)
send rpc with int value 3
remote side receives value of 3
if (rpc value of 3) { animation.play("dance") } else { animation.play("idle") }
You could also use a case/switch statement to break your codec apart which is usually a bit better than if's for organization and understanding (when you have to come back to it 3-4 months later and wonder what you were doing)
This type of 'codec' concept has a wide variety of uses - for example if you make it a string:
rpc send string of "152"
on other end parse your string out to 3 ints (and make sure that's what you're always sending or filter out the garbage)
when you peel the first int of 1, that's what you look like (model choice?), peel the second int of 5 that's your current playing animation (check to see if its already playing, if not - do it), and peel the third int of 2 and that's your weapon wielded (and.. if its not ... wield it).
This is all optional example of course. It can very big time. There are dozens if not hundreds of ways to do it.
Hi, thanks for the answer. I'm a student working on a game, I have my exams in a week and I have been frying my brain over this the entire day. I'm using unity's built in networking, right now this confuses me, so I'm going to sleep since I just cant concentrate anymore. I'm going to look at this tomorrow and see if I can work it out. I dont like asking for code, but if you could write a small example, a line or two, for me to comprehend, it would be amazing. Thanks in advance, going to sleep.
Hmm. Well I wrote up a page for you with 2 code samples and it refused to let me post another answer - I should have used comment :( - it erased it all.
In short go try out http://docs.unity3d.com/$$anonymous$$anual/net-RPCDetails.html
$$anonymous$$ake sure you have 2 clients and a server running that's the $$anonymous$$imum for a unity network setup so you can see what's going on proxy side.
Hi again. I already looked this, but the RPC confuse me a ton. Could you try and write a small example again? Showing how to "activate" an animation for another player to see.I tried writing it myself, ended up with loads of RPC errors, and when they were finally all gone, nothing happend. Thanks again
Your answer
![](https://koobas.hobune.stream/wayback/20220613200118im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
unity network animation problem 0 Answers
Multiple Animation 1 Answer
play animations (multiplayer) 1 Answer
Problem with animation RPC in Photon 1 Answer
Animation Running Game 0 Answers