When the direction is negative, you do velocity.y -= speed
, but when the direction is positive, you do velocity.y = speed. -=
is just short hand for velocity.y = velocity.y - speed, meaning you keep substracting speed every frame, which makes your enemy accelerate. But velocity.y = speed
is only setting the velocity to 50, meaning if it were moving, it would do so a lot slower than the other direction. My guess is that the enemy is moving, but you don't notice since the velocity is so low in the up or right directions. If I'm correct, then you also haven't tested the left direction, since you use -=
there as well.
I guess that for forward and right, you meant to write velocity.y += speed
and velocity.x += speed
respectively.