Finding Touching Faces Based on Rotation for Cubes in 3D
I have this pretty specific problem that I haven't been able to find an answer to. I tried googling it but I'm not really sure what I should look for.
The problem: Cubes have 24 possible rotations in 3d where they line up with the original (24 possible rotations by increments of 90 degrees). If I have two cubes that are touching, where they can be touching each other on any face (above, below, on the right, etc.), and they both are rotated by some multiple of 90 degrees, based on their positions and their rotations how can I efficiently tell which two faces will be touching, and the relative rotation of those faces? in this example, side 6 would be touching side 6, where the second is cube rotated 90 degrees relative to the first.
Side question, if I know that these objects will be at 90 degree rotations, what data type should I use? (quaternions seem pretty big for what I'm doing)
Hi, I have the same problem. If you found the answer, can you help me to solve?
Answer by andzq · Oct 24, 2020 at 03:45 AM
You might just assign a gameObject to each side of a cube with a small collider plus a tiny script that simply contains the assiociated eye count of that side. Then check for overlapping colliders. From overlapping colliders, get the script with GetComponent and read out the assigned eye count. If you position the collider-gameObjects so that their local "up" is pointing away 90° from the surface of the respective side you should be able to measure their relative rotation to each other by comparing the 'y' value of their transform.localEulerAngles.
That said, I gave this interesting problem a try with another approach and built a small test environment that you can check for yourself here ->>: diceGit
some screens: img_1 img_2 img_3 img_4
Your answer
Follow this Question
Related Questions
How can I make my game object move like this? 0 Answers
Problems when rotating object to animate in Unity 1 Answer
Rotation on moving using virtual joystick is not working as expected in 3D game. 0 Answers
Rotating a cube in 3D ,Rotating a cube into specific coordinates with given input 0 Answers
How to make a pseudo 3d object change sprites (animations) based on where the player is facing it 0 Answers