Top Down Shooter Aiming

Why would this not cause my player to rotate towards the mouse, assuming the camera is looking down on the player. Exactly vertical.

var currentGun : GameObject;

function Start () {

}

function Update () 
{
	var position = Input.mousePosition;
	var newPosition = Vector3(position.x,position.y,camera.main.transform.position.y- currentGun.transform.position.y);
	var lastPosition = Camera.main.ScreenToWorldPoint(newPosition);
	transform.LookAt(lastPosition);
	
}

Because your player’s orientation is not correct. Make sure your character’s forward vector is really the forward you want, so it looks in the direction of the z axis (blue arrow).

Dont use LookAt for anything not totally 3D, calculate your rotation angle manually instead.

there are many ways, here is one (might need to tweak it depending on your setup):

float angle = (Mathf.Atan2 (target.y, target.x) * Mathf.Rad2Deg) -90f;

Goodluck