Can somebody please help me with my code - what do i need to add to make my camera turn SMOOTHLY towards the enemy?

So i have this code and everything is working just fine - as soon as the enemy is within a given vicinity my players camera is turned towards it. As of now the camera just “jumps” directly into the new “lookAt position”…what do i need to add to make my player’s camera turn smoothly?

Heres my code (done in javascript):

var camLookAt : Transform;
var cameraUsed : Camera;
var Haunt : GameObject;


function SetCam()
{
	if(PlayerSpawnTrigger.spawning == true)
	{
		if(GameObject.Find("Haunt") != null)
		camLookAt.position = GameObject.Find("Haunt").transform.position;
	}
}



function Update()
{

	SetCam();

	if (GazeChecker.ForceGaze == true)
	{
		cameraUsed.transform.LookAt (camLookAt);
	}

}

Thx a lot guys :wink:

I may be wrong here but I would think using something like:

var camLookAt : Transform

function Update(){
    transform.LookAt(camLookAt * Time.deltaTime);
}

I could be wrong but it should be something along those lines.

Just posted a link cause I didn’t have much time. If you want full code, just use this:

var target : GameObject;
var speed : float;

function Update () 
{
    transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (target.transform.position - transform.position), Time.deltaTime * speed);
}