LookAt Slerp?

I’m working on a third person camera that follows where the player is looking at as follows:

var hit : RaycastHit;
if (Physics.Raycast(transform.parent.position, transform.parent.TransformDirection(Vector3.forward), hit) ) {
	transform.LookAt(hit.point);
}

There’s no problems with this code exactly, all compiles and works as intended, except I noticed a few jarring issues when the camera’s LookAt point snaps from a somewhat near wall to a distant wall (just drifting over a corner, for example). Is there a way to Slerp the LookAt so instead of instantly changing it would adjust quickly over a second?

I had a similair problem and got pointed in the direction of:

transform.rotation = Quaternion.Slerp( transform.rotation, Quaternion.LookRotation( target.transform.position - transform.position ), Time.deltaTime );

Hope it helps.

Regards,

MisterEd

Ah ha, thanks. I’ll give that a try.

Addendum:
Yup, that did the trick beautifully.

Feynt,

Wondering if you can post your code for using hit.point as a target for Quaternion.Slerp. I’m having a problem getting my transform to slerp toward a raycast hit.point. How did you solve this problem? Thanks for the help.