- Home /
Question by
system-idle · Feb 25, 2019 at 09:37 PM ·
rotaterotaion
Rotate gameobject with mouse/touch similar to meshlab or other 3D softwear
I've been looking around the net but can't find any examples of this (especially for Unity)?
There's the usual:
float h = horizontalSpeed * Input.GetAxis("Mouse X");
float v = verticalSpeed * Input.GetAxis("Mouse Y");
transform.Rotate(v, -h, 0);
But this doesn't give you accuracy when rotating a model in the way MeshLab or other 3D software wood.
I've tried to rotate GameObject based on collision point on mesh and origin with not much luck, and I would also like the rotation to work when the mouse/touch is not over the mesh, like MeshLab.
You can see the guy clicking around in MeshLab in this video and how the model is moving in relation to his mouse: https://www.youtube.com/watch?v=FGaNv23Xvtw
Any ideas/pointers to get this working in Unity?
Comment
Answer by WarmedxMints · Feb 26, 2019 at 07:59 AM
I've just done a bit of work on rotating gameobjects, I think what I have done here should help - https://github.com/WarmedxMints/Unity3d-PhysicsGun