okay so the code below works… except for one problem…
he wont face toward the player and he seems to “Run away” from the player insted of move towards him. and when he stops sometimes he just spins endlessly… and stops moving around all together.
help?
var target : Transform; //the enemy’s target
var moveSpeed = 10; //move speed
var rotationSpeed = 3; //speed of turning
var myTransform : Transform; //current transform data of this enemy
function Awake()
{
myTransform = transform; //cache transform data for easy access/preformance
}
function Start()
{
target = GameObject.FindWithTag("Player").transform; //target the player
}
function OnBecameInvisible () {
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}