# How to control the turnrate of player towards the mouse?

So I’m making a top down space shooter (in 3d) and I’ve managed to get the ship to follow the mouse cursor as I wanted and with quaternions involved. But how would I use Quaternion.Slerp in this code to make it so that the ship is slightly slower to turn towards the mouse when it is following it? I’ve tried implementing quaternion.slerp into the script but I don’t understand how I’m supposed to implement it.

``````void Update()
{

// Create a raycast from the camera to mouse position
Ray lastMousePos = Main_Camera.ScreenPointToRay(Input.mousePosition);
Ray cameraRay = Main_Camera.ScreenPointToRay(Input.mousePosition);
Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
float rayLength;

// if statement for making the player rotate towards the mouse position
if(groundPlane.Raycast(cameraRay, out rayLength))
{
Vector3 pointToLook = cameraRay.GetPoint(rayLength);
Vector3 lastPointToLook = lastMousePos.GetPoint(rayLength);
Debug.DrawLine(cameraRay.origin, pointToLook, Color.blue);
Quaternion qPointToLook = Quaternion.Euler(0, pointToLook.y, 0);
Quaternion qLastPointToLook = Quaternion.Euler(0, lastPointToLook.y, 0);
Vector3 relativePos = pointToLook - lastPointToLook;

Quaternion LookAtRotation = Quaternion.LookRotation(pointToLook);
Quaternion LookAtRotationOnly_Y = Quaternion.Euler(transform.rotation.eulerAngles.x,
LookAtRotation.eulerAngles.y, transform.rotation.z);

transform.rotation = LookAtRotationOnly_Y;

}
``````

So how would I go about changing this to make the ship

Hello @LargeEgo,
It depends much of the behavior of the smoothing you want, does this work for you (did not test it - might want to twick transform.rotation a little) ?

``````float smooth = 15f; // Whatever
Quaternion LookAtRotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(pointToLook), smooth * Time.deltaTime);
``````