I have a cube that I am rotating with the keyboard, like so (inside update() )
// Get delta from inout
Quaternion rotX = Quaternion.AngleAxis (Input.GetAxis ("Horizontal") * rotationSpeed, Vector3.right) // X rotation
// Apply rotation
this.transform.rotation *= rotX;
// Do the same for Y…
When I press left, the object rotates to the left as expected, the same goes for right. However when I move my camera around the back, pressing left makes it rotate right, and pressing right makes it rotate left.
I figured out that if I work out the rotation between the camera and the object, I should be able to subtract this from my overall rotation and get the difference (works on paper) but I can’t seem to figure out how to implement this in code. The nearest I can get is to make my object always face the camera
I would like the left key to rotate “left” no matter the camera position (and of course to work with the Y and Z axis, as I intend to replace the keyboard with a LapMotion device).
Any suggestions?