Hey, I have two boxes trying to get one to chase the other, but it wont move :/
This is the code:
var enemy: Transform;
var player: GameObject;
var dir: Vector3;
var speed: float;
var observed: boolean;
function update () {
if(observed){
dir = player.transform.position - transform.position;
dir = dir.normalized;
transform.Translate(dir * speed, Space.World);
}
else {
transform.eulerAngles.y = Mathf.PingPong(Time.time*20,90) -45;
}
}
function OnTriggerEnter (other:Collider) {
if(player) observed =true;
}
put a debug log in each part of the function and find out exactly where the script gets to. Post back here with the results and then you will definatly be closer to getting your question answered.
– anon61858128