Multiple animations on the same GameObject won't work
I don't know why but this code won't work on my zombies, I have a Zombie prefab with a Animation component that contains 2 animations : Attack and Walk. These zombies are supposed to walk all the time and stop walking when they get to the last point of their path.
void Update()
{
Distance = Vector3.Distance(Path[CurrentPoint].position, transform.position);
transform.position = Vector3.MoveTowards(transform.position, Path[CurrentPoint].position, Time.deltaTime * Speed);
if (Distance <= ReachDistance)
{
CurrentPoint++;
}
if (CurrentPoint == 2)
{
transform.Rotate(0, Angle, 0);
}
if (transform.position== Path[3].position)
{
GetComponent<Animation>().Play("Attack");
}
else
{
GetComponent<Animation>().Play("Walk");
}
if (ZombieHP <= 0)
{
transform.rotation = Rotation;
transform.position = Path[0].position;
CurrentPoint = 0;
ZombieHP = 150;
}
}
This is the Update() of my prefab, the problem is when the zombie gets to the last point of the path it keeps walking and its OnTriggerEnter() stops working.
Thanks in advance.
Your answer
Follow this Question
Related Questions
Animations created in Runtime 0 Answers
How do you trigger an animation with your Player? 1 Answer
How to make a mecanim animation into a prefab? 0 Answers
Player prefab being unassigned when enemy is instantiated 1 Answer
how to make a fall animation play when walking of an edge and a landing animation 0 Answers