- Home /
Question already posted at http://answers.unity3d.com/questions/185346/rotate-object-to-face-mouse-cursor-for-xz-based-to.html
Rotate an OBJECT along Y axis to look at mouse cursor
Normally I'd avoid posting something so frequently discussed, but I've read and tried every solution proffered in the other threads and none of them have addressed the problem.
One reason, among several, is that the solutions I've seen calculate the desired rotation angle based on the camera's orientation to the mouse cursor and then rotate the camera to match. This is not desirable.
Instead, I want to rotate just the object to face the cursor, leaving the camera's orientation intact.
Conceptually, I think that I need to get the x/y screen location of the cursor, calculate the difference in angle between the cursor's position and the objects's front vector and then rotate the object along the y axis so that the front vector intersects with the cursor's position.
Caveats: I'm not a strong coder, and I've been using uScript for a lot of my work so far. Anything prescriptive that you can provide to get me over this hump is greatly appreciated, and I know a lot of other people have been wrestling with the same issue.
Follow this Question
Related Questions
Trouble with controls on top down fixed camera game. 1 Answer
Can't use camera.main [SOLVED] 1 Answer
RayCasting shows wrong point 1 Answer