Third person view / lock on

I currently have a third person controller where I can move the camera around my character and started implementing a lock on system that disables your rotate camera controls and then uses the lookAt function that should keep your third person controller constantly looking at the main character / enemy. The problem is that it doesn’t seem to work at all, the controls become disabled but it will not lock onto the enemy. Has anyone else successfully implemented third person lock on into your game ? Not sure why it wouldn’t be working.

couldn’t you lock it and then create a variable transform called enemy

var enemy : Transform;

then in your code where you want it to lock on

enemy = gameObject.Find("enemy").transform;

transform.LookAt(enemy);

otherwise create a boolean

var lockOn = false;

and then

if (lockOn == true)
{
    transform.LookAt(enemy);
}

hope this helps! :slight_smile: