After adding the animation idle state my enemy formation doesn’t move according to the EnemySpawner script anymore. The enemies just animate in and stay in the end position of the animation - no left-right movement.
void Update ()
{
// movement
if (movingRight) {
transform.position += Vector3.right * speed * Time.deltaTime;
} else {
transform.position += Vector3.left * speed * Time.deltaTime;
}
float rightEdgeOfFormation = transform.position.x + (0.5f * width);
float leftEdgeOfFormation = transform.position.x - (0.5f * width);
if (leftEdgeOfFormation < xmin) {
movingRight = true;
}
if (rightEdgeOfFormation > xmax) {
movingRight = false;
}
if (AllMembersDead()) {
SpawnUntilFull();}
}