3

I've been looking around the internet for a few days now, and I can't really find an answer that i can understand well enough to rotate my Rubik's Cube.

I have made my own 3D Model using Blender of a Rubik's Cube and imported it in to Unity which is what I'm going to use to rotate the faces.

But I just don't seem to understand the mathematics involved in rotating a Rubik's Cube, should i use Matrices? If so how do i couple it all together for it to work?

I can rotate a single side around by grouping the bricks together by faces, but the moment you turn the next face it would completely disrupt the other one.

Thanks a lot!

Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
Nicholas
  • 783
  • 2
  • 7
  • 25
  • `but the moment you turn the next face it would completely disrupt the other one` - Isn't this exactly what makes solving a Rubik's Cube so hard? – Bobson Mar 22 '13 at 14:13
  • Nope, no college assignment. I'm studying on my own. @Bobson I'm sorry if it was unclear, i meant that it would destroy the "GameObject face".. i know how a rubiks cube works :P – Nicholas Mar 22 '13 at 14:17
  • @balls - Ah, that makes sense now. – Bobson Mar 22 '13 at 14:18
  • hi @Nicholas - would you mind "Tick"ing this old QA you started? thanks. – Fattie Apr 18 '16 at 15:07
  • @JoeBlow Hi - I don't mind at all, however I was hoping for more answers but they never came - I guess the only one here will do. :) – Nicholas Apr 20 '16 at 07:18

1 Answers1

4

My idea: Keep each of the 26 blocks as separate GameObject objects (8 corners, 12 edges, 6 centers), with each block's origin in the center of the cube. Separately you keep track of which block is currently where on the cube, for example in a 3D array.

Then when a face needs to be turned:

  • Find out which blocks belong to the face.
  • Rotate each of those blocks around the axis of rotation (through the middle of the cube) using Unity's normal rotation functionality.
  • Update the information on which blocks are where.
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157