Question by
unity_iLZ1gb2l4qwIwQ · 5 days ago ·
animationswitch characters
What can I change that my players only get an animation if they are my current active player?
I am working on a game where you can switch between different players but every player should have their own animation when they are active.
I got the following scripts:
Mind Script
void Start()
{
for (int i = 1; i < Players.Length; i++)
{
Players[i].GetComponent<Movement>().enabled = false;
}
CurrentPlayer = Players[0];
}
public void ChangePlayer(GameObject player)
{
CurrentPlayer.GetComponent<Movement>().enabled = false;
CurrentPlayer = player;
}
}
And Animation Script:
void Start()
{
animator = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKey(KeyCode.D))
{
animator.SetBool("isWalking", true);
}
else
{
animator.SetBool("isWalking", false);
}
}
}
At the moment when my first player moves, my second player (the animation is for the second player) does the animation while he is not active.
How can I change it that my players only get an animation if they are my current active player?
Comment
Your answer
Follow this Question
Related Questions
Switch player model, positon, camera and animate 0 Answers
my animation glitches when i add more keyframes 0 Answers
How to add bones to a mesh 0 Answers
Can Not Load Animation of Jump 0 Answers
Ragdoll Collider problem 0 Answers