Thank you for visiting → Compete For Nothing.com ← If you find anything useful leave me a comment and share. Interested in Arduino, C#, Unity3D, Game Creation, VB.NET, learning and most important of all Sharing!.
Close Notification
Open Notification

Sync Animation State Unity3D Using RPC C#

Sync Animation State Unity3D Using RPC C#
GARD Pro Not Registered

 

Simple RPC  call to sync animation state, it could be used to send what ever data you wanted to sync eg health, object held by a player ect. I am really not sure if using RPC for animation states is good practice but it will get you going on how to use it.

GARD Pro Not Registered

In my example we have the following

GARD Pro Not Registered
  • void WalkAnimation()
  • void RunAnimation()
  • void SyncAnimation()

 


 

So say I wanted to sync the walk animation animation when I pressed the “W” key I could call it from the function like this

 

if(Input.GetKeyDown(KeyCode.W)) {

//player is walking lets sync the animation
WalkAnimation();
}

if(Input.GetKeyDown(KeyCode.R)) {

//player is running lets sync the animation
RunAnimation();
}

That is a really simple way of implementing it and not really recommended.

GARD Pro Not Registered

networkView.RPC(“SyncAnimation”, RPCMode.All, 0);


networkView.RPC

This tells unity we want to send an RPC


“SyncAnimation”

This is the function we want to send


RPCMode.All

We want to sent it to ALL other networkviews


0

This is the data we are actually sending in this case we are only sending and integer which saves on bandwidth.


Dogecoin
Donate Dogecoins: DGkJRWQCyBUeXbenYz18LRN9X67aora9nz Whats This?

1 Comment

Leave a Reply to Chester Cancel reply