- Home /
Calculating the rotation of an object, when the top is forward
Hey everyone!
I've been struggling with this problem for a while, I think I can explain it better with pictures than my words. So If I want to rotate the top to forward like this with no rotation already done:
It's quite easy to figure out the rotation of the dice, It's just -90 degrees to the Z rotation. But when I try to do it with an already rotated dice thing happen, which i don't know how work:
Can somebody help me understand how does this works, or how to calculate the rotation If I have the start rotation and for example I want to rotate it in the world's X axis?
Thank you for your answers!
Answer by Acegikmo · Apr 28, 2020 at 08:41 PM
You can use transform.Rotate() and specify both axis and angle, as well as if you want to do it in local space or world space
Thank you, but out of curiosity, is there a way to calculate the Quaternion it will be on after this rotation?
Sure! You can use quaternions directly to get a rotation representation out of your existing rotation. $$anonymous$$ind that these are order dependent though, so a*b is not the same as b*a, so it might give you unexpected results if the order is incorrect
Quaternion rotation = transform.rotation * Quaternion.Euler( 0, 90f, 0 );
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Flip over an object (smooth transition) 3 Answers
Rotate player (rigidbody) towards his movement 2 Answers