Character Rotation to the mouse

I’m trying to make it so the character rotates on the cursor, but the problem is that the way my camera is most methods i find wont work. I don’t want to use a BodyGyro to make this work, but to use the humanoid’s root part to do the rotation. I saw a post that referenced Camera:WorldToViewportPoint(), but I have never used this before. Could anyone help me write up a solution to this?

(Screenshot of top down camea. Basically 3D / 2D)

1 Like

I don’t think that is the function you are looking for.
My approach to this goal is I would use UserInputService.GetMouseLocation function to get the mouse’s 2D position on the screen, then plug that into Camera.ViewportPointToRay to create a ray. After this, check the point of intersection of the ray if it hits something, and use the point as a reference point for the character’s rotation. Only down side of this that I could think of is that if you hover the mouse over a void, point of intersection would be nil.

I hope this helps!

2 Likes