# Tag Info

## Hot answers tagged quaternion

2

transform.rotation is not an Euler angle triplet. It is a quaternion. So its z component is not a rotation angle that you can pipe through Quaternion.Euler meaningfully. If you want to apply only the roll of one object to another, you can do something like this: child.transform.rotation = Quaternion.LookRotation(Vector3.forward, transform.up); This forms ...

2

Turns out my quaternion rotations are completely fine. Positive rotations are CCW in right-handed coordinate systems[1]. My rotation matrix functions were the ones rotating backwards! And in fact they were transposed by mistake. [1] https://www.evl.uic.edu/ralph/508S98/coordinates.html

1

Turns out the solution to the fundamental problem is to avoid the complicated math and just use an appropriately-configured HingeJoint. When a player grabs an object, set node A to a kinematic body child node of that controller, and set node B to the object being grabbed. Set both paths to empty strings when they let go. The actual result is a little wonky, ...

1

New Answer Since you have two vectors to begin with, instead of two quaternions, Find the quaternion representing the rotation from one vector to another. Then you can take a copy of the current rotation quaternion, and multiply it with the quaternion you got from the vectors, which gives you the final rotation quaternion. You can then lerp from your copy ...

1

First, take the center and radius out of the equation, and just think of your two camera locations as directions - unit vectors pointing out from 0: (For brevity, I'll pretend we're using a vector library so we don't have to repeat everything 3 times for x y & z) // Unit vector in direction from focus position to the old camera position. camDirection = ...

1

For my use case I was able to use transform.localScale and modify it's Y-scale as a solution to my issue. I simply got a proportion of my trigonometric calculation's result and turned it into a value between -1 and +1. It has the exact effect as I was looking for, and is definitely more stable.

1

I'm not sure I entirely grok what you're going for, however if you're looking to set one axis explicitly a good choice is Quaternion.LookRotation This will set the forward axis to pointing at whatever you want, while spinning the rest around that axis in such a way as to keep the up axis pointing as "Up" as possible. The nice thing is, "Up" is another ...

1

What I believe @ratchet freak means when he says "apply" is to rotate each of the original front, right and up vectors around the orientation quaternion. I'll just leave this implementation based off this OpenGL FPS Camera Quaternion tutorial here for future reference. (I had to invert the quaternion to get working camera controls, others may not need to). ...

Only top voted, non community-wiki answers of a minimum length are eligible