I have been having a really bad time trying to find a way to torque a rigidbody around to a target rotation based on its current rotation; the Euler angles are flipping randomly because they’re being extracted from a quat.
Anyway, it occurred to me that I may be able to find the difference in rotation between the two objects (the rigidbody and the target bone) using the directional vectors stored in Transform
. In my mind this should be theoretically possible.
What I want to do, specifically, is take the Transform.Forward/Up/Right
vectors of one object and compare the angles between the points to the Transform.Forward/Up/Right
vectors of the other object.
I’m not sure how this would be achieved, but I’m sure it must be possible. I’m no maths guru by any standard, ha, and I’m struggling to visualise how it would work. If it turns out this is not possible for some reason…well, I may just have to cry a little as this may be my last hope for being able to complete my game in Unity…
Any help would be much appreciated, and if my question is worded badly or missing information, please don’t hesitate to tell me
One last thing: I can’t use Quaternions during any stage of this process, because if I do, I have no way of getting Euler angles out again without them being mucked up.
ADDITIONAL INFORMATION
Ok, so I’ve worked out how it would work (for all of the following, assume 0,0,0
is the origin of the angles):
- To calculate the rotation of the X axis, you calculate the angle between either the Y and Z values of
T1.Forward
or those ofT1.Up
, and the Y and Z values ofT2.Forward
orT2.Up
. - To calculate the rotation of the Y axis, you calculate the angle between either the X and Z values of
T1.Forward
or those ofT1.Right
, and the X and Z values ofT2.Forward
orT2.Right
. - To calculate the rotation of the Z axis, you calculate the angle between either the X and Y values of
T1.Up
or those ofT1.Right
, and the Y and X values ofT2.Up
orT2.Right
.
I THINK those are correct, but I really don’t know, and it just occurred to me that I don’t know what would happen if any of those coordinates ended up 0,0
… Now the only thing I need to know (aside from what to do about the coords being 0,0
) is how to actually calculate angles between to points with 0,0,0
as the origin.