i am a noob, looking for advise. i instantiate a moving enemy and want to track it’s changing transform. Unfortunately i only get the transform from start although i see the enemy moving on the screen.
Instantiating my enemy:
public var enemy : GameObject;
function Start () {
Instantiate(enemy, Vector3(5.886453,0.4570506, 4.031569), Quaternion.identity);
}
function Update () {
Debug.Log(enemy.transform.position);
}
Script attached to my enemy-prefab:
var speed : float = 5;
function Update () {
transform.Translate(Vector3(speed,0,0) * Time.deltaTime);
}
when i press play, the console keeps printing 0,0,0 although my enemy prefab is moving.
how can i get the updated real transform of the enemy?
public var enemyModel : GameObject; //The reference
public var enemy : GameObject; //The actual enemy
function Start(){
enemy = Instantiate(enemyModel, Vector3(5.886453,0.4570506, 4.031569), Quaternion.identity);
}
function Update(){
Debug.Log(enemy.transform.position);
}