Finding a rolled dice rotation around axis

Hello,
First post here, nice to meet you all :slight_smile:
I have a problem to solve which I’m not sure how to tackle.
I have a Dice - it’s an GameObject with 3D mesh and a box collider. As children, I have 6 planes with texture placed around it to imitate dice sides.
I place the dice in the air and when game starts, I add some force and torque. After it lands what I want to do is to rotate the dice so that the symbol visible at the top is presented in a more understandable way (as per image).
7558684--934876--upload_2021-10-9_0-51-50.png

I could try to do the simplest thing, which is just using Quaternion.AngleAxis( X, Vector3.up) but the problem is that I don’t know how much I need to rotate to get to the point I want to be at. For that I would need to get the current angle and calculate it.
However, I don’t know how to get that angle. What I have done is I found which dice axis is parallel to the Vector3.up (by using Vector3.Dot() ), however I’m stuck here as I have no idea how to extract the current angle according to that axis (becuase the X,Y,Z I am getting are still according to the world axises IF I udnerstand that correctly).

Any help would be appreciated.

You need to know which side is up.You can calculate that from gameobject’s final rotation. And you already know which side is up when it is Quaternion.identity so you can find it. But in your case, since you have 6 planes, it would be easier to find the plane which has higher Y location. So if your cube is from 1x1 planes, then the plane which has 1 unit Y location is the upper one. Then you’ll know it’s rotation amount to fix the view.

Since you’re viewing it from top with a camera (Let’s assume camera forward is perpendicular to plane), you can get camera’s -Y direction.

Now you need to find angle between plane’s -Y(it can be others whichever is bottom) vector to camera’s -Y vector with Vector3.Angle.