2D Rotation Toward Vector3 Direction

Hello,
I’m trying to figure out, how given input in the horizontal and verticle axis, that I can rotate a player towards that direction using the 2D tools in Unity. So far, from looking around the internet, I have been able to rotate the player but it rotates around every axis except the Z axis. This essentially stops the player from being visible.

private void RotatePlayer()
{
    float horizontal = Input.GetAxis("Horizontal");
    float vertical = Input.GetAxis ("Vertical");

    if( !m_netHandler.IsOwner())
    {
	    horizontal = m_clientLastHorizontalInput;
	    vertical = m_clientLastVerticalInput;
    }

    if(horizontal != 0 || vertical != 0)
    {
	     Vector3 desiredDirection = new Vector3(horizontal, vertical);
	     m_desiredDirection = Quaternion.LookRotation(desiredDirection.normalized);
    }		

    transform.rotation = Quaternion.Slerp(transform.rotation, m_desiredDirection,      
                                          Time.deltaTime * m_rotationSpeed);
}

Any ideas would be helpful. Thank you.

Try making this change:

 if(horizontal != 0 || vertical != 0)
    {
         float angle = Mathf.Atan2(vertical, horizontal) * Mathf.Rad2Deg;
         m_desiredDirection = Quaternion.AngleAxis(angle, Vector3.forward);
    } 

Note this change assumes that the ‘forward’ of the sprite is to he right, so you may need to rotate the texture or modify the value of ‘angle’ before you pass it to AngleAxis().