# Rotate the player to face where the mouse is pointing

I know very similar questions have been asked and, knowing unity, the exact question I’m asking has been asked. I’ve looked on unity answers for 2 days looking for an answer but I haven’t found it,if there is already an answer out there just link it to me.
I am making a 3rd person game where the player controls a space ship. I currently control the rotation of the ship with the keyboard, but I want to control it with the mouse.
I have found a script on unity answers that makes the ship literally face the mouse, but I want the ship to face where the mouse is pointing. The current script I have means that if I put my mouse in the middle of the screen, the ship faces me, this is not what I want. If my mouse where in the middle of the screen I want the ship to face directly away from me, at the mouse as if the mouse is further away from the camera than the ship.
Here is what I have so far:

``````var lookFactor = 0.8;

function Update () {
var distance = (transform.position.z - Camera.main.transform.position.z)*lookFactor;
var position = Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
position = Camera.main.ScreenToWorldPoint(position);
transform.LookAt(position);
}
``````

But like I said this makes the ship face the cursor, not where the mouse is pointing in the world. Any help appreciated.

Actually it’s very easy - change lookFactor to value greater than 1

This way, your distance variable will be greater than z distance from camera to transform, while now it is lower.

I found this to be rather cute (Skip to the end to see the final result)
I also just came across this, while I was fetching the previous link, do they help you?

thanks for your help and the links, ArkaneX found the answer in my original code, the look factor was too small

``````var lookFactor = 10;

function Update () {
var distance = (transform.position.z - Camera.main.transform.position.z)*lookFactor;
var position = Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
position = Camera.main.ScreenToWorldPoint(position);
transform.LookAt(position);
}
``````

I am now asking another question (weapon aiming in 3d space using the (2d) mouse - Unity Answers) regarding mouse controlled weapons in 3d space