3D Isometric Aim at Cursor issue

Hi all,

I’m working on a character controller, I have my locomotion system and animation systems set up but having some issues lining the players rotation to the mouse position. This is generally fine on the Y axis, but on the X axis its out quite a bit.

I know that this is because my camera is rotated 30 degrees on the X axis, but not sure of the solution. How would I take this into account in my code and make the player always aim toward the mouse position as it is on screen?

I’ve attached some images where I’ve made a little red object as a way to visual where the raycast is hitting in world space vs the mouse screen position. Ideally I’d like the character to rotate to the mouse position as it is on screen - does anyone have any ideas?

Here’s the raycast code from my rotation script:

private void HandleRotation()
{
    Vector3 mouseScreenPos = Mouse.current.position.ReadValue();
    Ray mouseRay = Camera.main.ScreenPointToRay(mouseScreenPos);
    if( Physics.Raycast(mouseRay, out RaycastHit mouseHit) )
    {
        SmoothLookAt( mouseHit.point );
    }
}

Pictures of the issue:

This is resolved.

This video is a great resource for understanding the problem: