so, what I’m trying to do is make it so when the Box Collider (as trigger) that is tagged “vision” moves over the trigger on a doll, the doll will not rotate, but when it’s off, the doll will turn with LookAt and look at the player… So long as they’re watching it, it won’t move at all.
So far, it will only start looking at the player after the tagged player object, itself, enters the trigger area (which is too close to be of use for a horror game), and then it won’t turn off at all… What am I doing wrong?
This is the script I have…
#pragma strict
var target : Transform;
var looking = true;
function Start () {
target = GameObject.FindWithTag("Player").transform;
}
function OnTriggerEnter(other:Collider) {
if(other.gameObject.tag=="vision")
{
looking = true;
}
else
{
looking = false;
}
}
function Update () {
if(looking == false)
{
transform.LookAt(target);
}
}
thanks in advance!