Ok so I have my AI script and an empty gameobject declared a trigger so when you come in contact with the trigger the enemy comes at you. So the enemy follows me but he is turned sideways and he adjust’s sideways even if I move in front of him. I’m thinking the problem is that the game thinks the side is his face and turns it to adjust there. Can someone help me fix this please?
My AI Script Code:
var target : Transform;
var enemy : Transform;
var moveSpeed : float = 1.0;
var inRange : boolean = false;
function OnTriggerEnter() {
inRange = true;
}
function OnTriggerStay() {
inRange = true;
}
function OnTriggerExit() {
inRange = false;
}
function Update() {
if(inRange == true) {
enemy.transform.LookAt(target);
enemy.transform.position = Vector3.Lerp(
enemy.position, target.position,
Time.deltaTime * moveSpeed);
enemy.animation.Play("Take 001");
enemy.animation.Stop("idle");
}
if(inRange == false) {
enemy.animation.Stop("Take 001");
enemy.animation.Play("idle");
}
}
PS Ignore the animations