Reputation: 3489
I am working in Unity3D and I was wondering how I would rotate a cube based on the angle between the cube and the mouse position. With that I don't mean the mouse position in world space but in pixels.
Upvotes: 1
Views: 137
Reputation: 2803
Here are some pages that'll lead you to your answer:
Input.mousePosition
This also includes an example of how to turn screen coordinates into a ray in world coordinates. If you know how far away from the camera you want your point, check out ScreenToWorldPoint for a point instead of a ray.
transform.Rotate
To perform a rotation.
The rest of your question is kinda vague--rotating "based on" the angle between cube and mouse position could mean a lot of things. You shouldn't need much more information than this though!
Upvotes: 1