I've been looking at some other answers to similar cases but not every one used different methods, and a lot of them were not what i needed, so here's my question :

What's the best/standard way to get the X and Z positions of the mouse onto a plane, so that object can rotate to look at that position?

I'm trying to get it in a similar setting to, for example "Angry Bots" where the Player is always facing mouse position.

Also, would that be camera independent? i mean, if my camera changes its angle, it would still work because it usually is a projection of the "screen" plane onto the "player" plane, right?

I'm sorry, i'm a bit overwhelmed with the many options Camera.main. has, and i'm not really sure which one should i use.


I'm not currently at my computer to show a valid demonstration, however, I've used "Camera.main.ScreenPointToRay(Input.mousePosition)" casting that ray and referencing the point that it hits. You could set that point to be the position that your character looks at via Vector3.lookToward(). Also,you are correct, this would work regardless of camera angle as long say the raycast returns true.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.