void Update()
{
if (transform.position.x >= 6)
{
transform.position = new Vector2(transform.position.x - 1, transform.position.y - 1);
speed = -speed;
GetComponent().velocity = new Vector2(speed, 0);
}
else if (transform.position.x <= -6)
{
transform.position = new Vector2(transform.position.x + 1, transform.position.y - 1);
speed = -speed;
GetComponent().velocity = new Vector2(speed, 0);
}
}
In the original Space Invader, the enemies usually move first completely from left to right, then one step down, then completely from right to left, then one step down and so on.
Maybe you could move it similar instead of moving it in a diagonal line?
And somehow is it a bit strange that you move your enemy in parallel as well as by setting the transforms position hard-coded and by setting the rigidbodies velocity. Is there any special reason, why you use this 2 different approaches together?