I know this question gets asked a lot but I still couldn’t fix my problem, even after searching for hours.
I have a skeleton prefab and I placed two of them into my Scene. Their animations can transition from any state into hurt and dead and back through a trigger and this works with both of them. They can also transition from idle to walking and attacking through booleans and this only works for on of them. The other just stays Idle
public class Chase : MonoBehaviour {
public Transform player;
static Animator anim;
// Use this for initialization
void Start ()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update ()
{
if (GetComponent<CharacterStats>().isDead) return;
Vector3 direction = player.position - this.transform.position;
float angle = Vector3.Angle(direction,this.transform.forward);
if(Vector3.Distance(player.position, this.transform.position) < 10 && angle < 90 && !player.GetComponent<CharacterStats>().isDead)
{
direction.y = 0;
this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
Quaternion.LookRotation(direction), 0.1f);
anim.SetBool("isIdle",false);
if (direction.magnitude > 2)
{
this.transform.Translate(0,0,0.05f);
anim.SetBool("isWalking",true);
anim.SetBool("isAttacking",false);
}
else
{
anim.SetBool("isAttacking",true);
anim.SetBool("isWalking",false);
}
}
else
{
anim.SetBool("isIdle", true);
anim.SetBool("isWalking", false);
anim.SetBool("isAttacking", false);
}
}
}
This is the code I use to set the bools. I’m guessing the first skeleton overrides the booleans set by the second, but how do I avoid that? I’m planning on making many skeletons so duplicationg the skeleton controller for every skeleton would be too much work.