So I was making multiplayer of my game. Everything works fine, at first I had 2 animations for the ‘3rd person multiplayer character’ for other players to see, those animations were idle and walking. I have a variable named PlayerState on my singlePlayer character, 0 for idle, 1 for walking, and 2 for sprinting. I then linked it to my multiplayer character, and it worked fine with walking and idle. When I added the sprinting, it would start at idle, then I walk, it plays walking animation, but when I stop walking, it plays the sprinting animation when I’m idle and plays idle animation when I sprint. I’ve done Debug.Log to check the PlayerState, and it is correct, being 0 at idle and 2 at sprint. I also checked the animations, so the sprinting animation is NOT named idle and vice versa. Is something wrong with my script? Here is the section involved with animation:
if(networkView.isMine && Player.networkView.isMine){
if(gameObject.transform.position != Player.transform.position)
gameObject.transform.position = Player.transform.position;
if(gameObject.transform.rotation != Player.transform.rotation)
gameObject.transform.rotation = Player.transform.rotation;
if(spine.transform.rotation != Player.GetComponent(MultiplayerPlayer).Spine.transform.rotation)
spine.transform.rotation = Player.GetComponent(MultiplayerPlayer).Spine.transform.rotation;
State = Player.GetComponent(PlayerScript).PlayerState;
if(State == 0){
animation.Play("multiidle");
} else if(State == 1){
animation.Play("multiwalk");
} else if(State == 2){
animation.Play("multirun");
}
Debug.Log(State);
}
This ‘Multi’ is my third person character that you see when you’re another player, and this Player variable is the first person one that you see of yourself.
Thanks in advance,
william9518