Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Making Enemy Retreat

$
0
0
Hello! I'm trying to make an enemy retreat after so many seconds after it's spawned. I tested out the transform.position and the enemy moves straight towards, so I know that part works. However, when I tried to make the time delay happen by using invoke() code and putting the transform code in a custom function, the enemy remains where it was spawned. #pragma strict public var enemyspeed : float; //how fast enemy goes private var retreatPoint: Vector3; //holds the coordinates to the retreat point private var step : float; //speed *frames value function Awake () { // sets speed of enemy var step = enemyspeed * Time.deltaTime; } function Start () { //after 4 seconds, bunyip retreats Invoke ("BunyipRetreat", 4); } function Update () { //coordinates for retreatingpoint retreatPoint = Vector3(24,0,20); } //custom function function BunyipRetreat() { //moves bunyip to retreating point transform.position = Vector3.MoveTowards(transform.position,retreatPoint,step); }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>