- Home /
Question by
FieryGrave · Jun 20, 2013 at 05:53 PM ·
animationnetworking
Animating over a network not working
Im trying to animate my networked game (just walking around right now) and im using the models velocity & rotation to figure out what movement animation to play (so i dont need to send anything over the network besides the objects current position)but i end up with choppy animations that look like they are lagging for everyone but the current client.
this is my current code
void Animate () { float velocityZ = (this.transform.position.z -lastPosition.z); float roatationY = this.transform.eulerAngles.y;
if ( velocityZ > 0)
{
if (roatationY > 270 || roatationY < 90)
{
animation.CrossFade("run", aniSpeed);
}
else
{
animation.CrossFade("back", aniSpeed);
}
}
else if (velocityZ < 0 )
{
if(roatationY > 90 && roatationY <270)
{
animation.CrossFade("run", aniSpeed);
}
else
{
animation.CrossFade("back", aniSpeed);
}
}
else if (this.transform.rotation != lastRotation)
{
animation.CrossFade("turn", aniSpeed);
}
else if(velocityZ == 0)
{
animation.CrossFade("idle", aniSpeed);
}
lastPosition = this.transform.position;
lastRotation = this.transform.rotation;
}
any way i can improve this?
Comment
Your answer
