How to make a game charachter rotate towards you when close enough?

like 5 meters in front of him, end then the game charachter rotates towards you.
I prefer the javascript code.

Thanks in advance (:

You can create a sphere in your scene, make it a child of the character’s game object and mark its collider as a trigger. Set the sphere’s collider radius to 5 ( for 5 meters ). Then place a script on the sphere that will contain the following code:

function OnTriggerEnter( Collider other )
     transform.parent.LookAt( other.transform.position );