- Home /
How do i animate threw network
Im trying to learn network so im working on a project to get better at it. All I need is this script converted to network so I can understand it.
heres the script
public GameObject head;
public Animation walk;
public int speed = 1;
public GameObject MouthOpen;
public GameObject MouthClosed;
public GameObject eyeLids;
void Start()
{
MouthClosed.active = false;
eyeLids.active = false;
}
void Update()
{
if(Input.GetKeyDown(KeyCode.T))
{
MouthOpen.active = true;
MouthClosed.active = false;
}
if(Input.GetKeyUp(KeyCode.T))
{
MouthOpen.active = false;
MouthClosed.active = true;
}
if(Input.GetKeyDown(KeyCode.B))
{
eyeLids.active = true;
}
if(Input.GetKeyUp(KeyCode.B))
{
eyeLids.active = false;
}
if(Input.GetKey(KeyCode.W))
{
animation.Play("Walk", PlayMode.StopAll);
animation["Walk"].speed = 14 + speed;
}
if(!Input.anyKey)
{
animation.Play("idle", PlayMode.StopAll);
animation["idle"].speed = 2;
head.transform.localPosition = new Vector3(0, 2.4f, 0);
}
if(Input.GetKey(KeyCode.LeftShift))
{
animation.Play("crouch");
head.transform.localPosition = new Vector3(0, 2.1f, 0.6f);
}
}
Answer by thornekey · Mar 16, 2014 at 10:39 PM
To animate through a network you need RPCs
use this to call the function when you move or whatever:
networkView.RPC("NetworkRun", RPCMode.All);
the function itself:
[RPC]
public void NetworkRun ()
{
animation.CrossFade ("player_run");
}
was just adding it
try it out and let me know if it works :) if it does please accept my answer as correct.
if your function is called WAL$$anonymous$$ you have to run
networkView.RPC("WAL$$anonymous$$", RPC$$anonymous$$ode.All);
try calling the rpc function after your Update function
Your answer
Follow this Question
Related Questions
Mono library to connect to Java/Python/Node backend? 1 Answer
Network.Connections 1 Answer
Photon network problem 2 Answers
Convas on Network 0 Answers
Connect to non-unity server with LLAPI 0 Answers