- Home /
Animating online users sprite
I've got a C Server and i send, every time a player moves, a packet to the server telling the new player position. Then i send back to all the other players the new position and the client updates it trough a Lerp. It all works great, the problem is when i've got to animate the clones. I'm animating them trough a controller assigned for each clone instance using the FixedUpdate(), i'm just checking if the sprite transform position equals to the stored one, if not it animates and stores the new x and y setting the animator status to "moving". If it does, it sets the status to "standing". The trouble is that due to server latency or whatever, many times the status becomes moving, then standing and then back to moving, so the animations just conflicts among them. I'm not sure how i should proceed to to get animations fluid.
Here is the controller:
void FixedUpdate()
{
if(instance == null) return;
Animator anim = transform.Find("PlayerSprite").GetComponent<Animator>();
isGrounded = Physics2D.OverlapCircle (groundCheck.position, 0.15f, whatIsGround);
anim.SetBool("Grounded", isGrounded);
if(instance.posx != transform.position.x || instance.posy != transform.position.y) { // is moving
anim.SetBool("Moving", true);
instance.posx = transform.position.x;
instance.posy = transform.position.y;
} else {
anim.SetBool("Moving", false);
}
}
Your answer
Follow this Question
Related Questions
ScriptableObjects and SyncVars, is it posible? 1 Answer
SyncVar issue 0 Answers
How to get transform syncing over network to work? 1 Answer
Variables not sync'd to clients 0 Answers
UNET: Client Host syncing problems 0 Answers