- Home /
Enemy moving left towards player.
I'm very new to Unity and coding, so I appreciate your patience.
I'm creating a 2D sidescroller where the character is always stationary on the left side of the screen. You have to use gesture attacks to prevent spawning enemies from getting to your character.
I've set up a spawner just outside of the screen towards the right and am hoping to figure out how to get the enemies that spawn there to simply move left towards the stationary protagonist. If they reach the protagonist, it's game over.
Can anyone help guide me? I've tried many different techniques but keep getting errors. I appreciate your help!
Answer by Namey5 · Jul 28, 2016 at 11:59 AM
#pragma strict
var speed : float;
function Update ()
{
transform.Translate (Vector3 (-1,0,0) * speed * Time.deltaTime);
}
(JS Example)
Just attach to the enemy objects.
Thank you! This is exactly what I was looking for. $$anonymous$$uch appreciated!
If you have got right answer please accept the answer . It may help others to find right answer