How to rotate to face mouse position using AddTorque (top down 3D)

I’m trying to use the below code to smoothly rotate an object to face the mouse cursor on the y axis. However, it only rotates to about 90 degrees regardless of where the cursor is.

How can I correct this?

//rotate to mouse position
float turnSmooth = 2.0f;
var targetPoint 		= Input.mousePosition;
var targetRotation 		= Quaternion.LookRotation(targetPoint - transform.position);
var targetAngle			= targetRotation.eulerAngles.y;
var currentAngle		= transform.eulerAngles.y;
var upAngleSmooth		= currentAngle + turnSmooth;
var downAngleSmooth		= currentAngle - turnSmooth;

//Turn conditions
if (targetAngle > upAngleSmooth){
    if (targetAngle - currentAngle > 180.0)
    {
        rb.AddTorque(new Vector3(0, -1, 0) * turnSpeed * Time.deltaTime);
    }
    else if (targetAngle - currentAngle < 180.0)
    {
        rb.AddTorque(new Vector3(0, 1, 0) * turnSpeed * Time.deltaTime);
    }               
}else if (targetAngle < downAngleSmooth){
    if (currentAngle - targetAngle > 180.0)
    {
        rb.AddTorque(new Vector3(0, 1, 0) * turnSpeed * Time.deltaTime);
    }
    else if (currentAngle - targetAngle < 180.0)
    {
        rb.AddTorque(new Vector3(0, -1, 0) * turnSpeed * Time.deltaTime);
    }
}

Your code for calculating the targetAngle doesn’t seem to work for me. It is always around 90 degrees, like you found.

var targetPoint = Input.mousePosition;
targetRotation = Quaternion.LookRotation (targetPoint - transform.position);
targetAngle = targetRotation.eulerAngles.y;

I think what you need to do is convert the object’s position to screenPosition. That way, your angle calculation is based off two screen positions: object and mouse.

Vector3 objectScreenPoint = Camera.main.WorldToScreenPoint (transform.position);	
var targetPoint = Input.mousePosition;
var lookDirection = targetPoint - objectScreenPoint;
lookDirection.y = transform.position.y; //Ensure only rotate on local y axis
targetRotation = Quaternion.LookRotation(lookDirection);
targetAngle = targetRotation.eulerAngles.y;

This will only rotate the object on its local y-axis. So the mouse y position isn’t used here.