Camera view

I made a script that rotates my player to my mouse, it looks like this:

But when I aim to the left it is not aiming at the mouse.

I figured out, when i go in straight topdown view it works and is correctly aiming at the mouse. But because I rotated the camera a bit it seems that it isn’t aiming at the mouse. But I don’t want my game to be straight top down, how can I get it right with a slightly rotated camera?

You want to do a Physics.Raycast with Camera.ScreenToWorldPoint of Input.mousePosition, find where the raycast hits, and have your character look at that point.

Yes I did that, it is working. When I put the camera right on top of the player it all works. But what I mean is, I don’t want my camera right from the top, so I rotated a bit. But now it creates the illusion that it isn’t aiming at the mouse when aiming to the left or right. But in reality it is aiming at the mouse if you look from it from straight topdown.