Question by
Peaknik · May 15, 2021 at 06:09 AM ·
movement script
Space Invaders clone enemy movement problem
I am doing a Space Invaders clone and I have problems with enemy movement. When enemies reach the edge of the screen they should go down a certain units and change direction. What happens is that they go very fast all the way down and disappear.
This is the function that controls that behaviour:
void EnemyDescend()
{
if (transform.position.x > 8.5 || transform.position.x < -8.5) // Descend if they reach the edges
{
gameManager.descend = true;
}
if (gameManager.descend)
{
transform.Translate(Vector3.down * downDistance * Time.deltaTime); // Descend
speed += 1f; // Changes speed movement
ChangeDirection(); // Changes direction movement
}
}
Any help would be greatly appreciated!
Comment