Transform.LookAt when enter trigger
I have a Model with Joints '.joint_Head' a 'camera (head)' and a box collider as a trigger
I'm trying to do the following
When the 'Camera (head)' enters the box collider, I want to apply the transform.LookAt on the '.joint_Head' to look at 'Camera (head)'. This would make the character look at me when I get into the collider
However I have no idea how to set what the Collider is in my script since I'm attaching the script to the joint.
This is what I have so far, I would set the target to the 'Camera (head)' but I have no method of defining what the collider is. So is there a way to define the collider used? or is there a way to define what the transform.LookAt is being applied to?
I can get it to work when there is no collider but that just makes the character always looking me regardless of where I am, it would be super easy to do custom box triggers on each of my models
public class Look_At_Cam : MonoBehaviour { bool yourVar;
public Transform target;
void OnTriggerStay(Collider target)
{
yourVar = true;
}
private void Update()
{
if (yourVar)
{
transform.LookAt(target);
}
}
}