- Home /
2D enemy movement to target
I cant figure out how i would do this. In the game the enemies spawn on the sides out of view of the camera and "walk" to a target in the certain of screen. The point is to stop the from pulling the target off the screen. I just want to know how i would get them to move. I used an instantiate script set so it shoots an enemy out but in order for it to reach the cameras view the gravity needs to be turned off. I tried transform position but i couldnt figure out how to give the object a speed to keep it from instantly moving to that point.
if anyone has any ideas it would really help.
Answer by GesterX · May 20, 2011 at 02:58 PM
Use Time.deltaTime. For example:
var speed : float = 10;
function Update () {
//move on the z-axis by 10 every second
transform.Translate (0, 0, speed*Time.deltaTime);
}
Your answer
Follow this Question
Related Questions
Player Instantiate rotaion problem 0 Answers
How can i instantiate a mesh at a hit point? 1 Answer
Spawn many object 1 Answer
Spawn enemies so they aren't spawned on top of each other (C#) 1 Answer
Enemy Spawning and Movement 0 Answers