Animator: multiple characters and one script
Hey, I'm trying to animate my 3d characters with animator. I have 3 enemies and they have the same script enemyController. My problem is now that every character has its own animator component. And if I try to play a move animation from the enemyController script, every character try to play his own animation. So my result of this is that only one character is using the animation and the others not. So I have one script but 3 characters with the same script. This is my script:
switch (action)
{
case 1:
if (GetIsAnimActive())
{
anim.SetTrigger("IsRunningChar1");
/*anim.SetTrigger("IsRunningChar3");
anim.SetTrigger("IsRunningChar4");*/
}
dirToGo = transform.forward * 1f;
break;
case 2:
if (GetIsAnimActive())
{
anim.SetTrigger("IsRunningChar1");
/*anim.SetTrigger("IsRunningChar3");
anim.SetTrigger("IsRunningChar4");*/
}
dirToGo = transform.forward * -1f;
break;
case 3:
if (GetIsAnimActive())
{
anim.SetTrigger("IsRunningChar1");
/*anim.SetTrigger("IsRunningChar3");
anim.SetTrigger("IsRunningChar4");*/
}
rotateDir = transform.up * 1f;
break;
case 4:
if (GetIsAnimActive())
{
anim.SetTrigger("IsRunningChar1");
/*anim.SetTrigger("IsRunningChar3");
anim.SetTrigger("IsRunningChar4");*/
}
rotateDir = transform.up * -1f;
break;
case 5:
if (GetIsAnimActive())
{
anim.SetTrigger("IsRunningChar1");
/*anim.SetTrigger("IsRunningChar3");
anim.SetTrigger("IsRunningChar4");*/
}
dirToGo = transform.right * -0.75f;
break;
case 6:
if (GetIsAnimActive())
{
anim.SetTrigger("IsRunningChar1");
/*anim.SetTrigger("IsRunningChar3");
anim.SetTrigger("IsRunningChar4");*/
}
dirToGo = transform.right * 0.75f;
break;
}
transform.Rotate(rotateDir, Time.fixedDeltaTime * 200f);
agentRB.AddForce(dirToGo * academy.agentRunSpeed, ForceMode.VelocityChange);
The reason why I commented the others is because I wanted to try an other way. I have set the parameter names of every animator same. So in every animator controller you have the param isRunningChar1. And I thought that it would work like that. But it didn't. Could you help me please.
Your answer
Follow this Question
Related Questions
Get current animation from animator and pausing it 0 Answers
Applying permanent mask to player animators walk 0 Answers
I can't see or access a state in the Animation Controler 1 Answer
Animation from child object overrided by its parent and won't show in game window 0 Answers
Can't change any values in the animation Window [w/ video] (bug?) 1 Answer