I haven’t solved a Rubik’s Cube in years, but for some reason a few days ago I woke up with an idea for something involving the fiendish little puzzle. Imagine, if you will, a Portal-esque lab environment (white cubes, weird moving machines, etc.). Then imagine that this place is actually the inside of a Rubik’s Cube.
Yes, I did just say inside.
My main “point” — if you could call it that — was that as the cube rotated so would you. If you happened to be in a rotating cubie, oriented vertical, and suddenly got turned on your side, “gravity” would now be pulling you sideways. And as you moved into cubies that hadn’t gotten rotated, you would enter them at an entirely different angle.
Of course, the mechanics of a Rubik’s Cube are insane to think about. Before reading on, ponder this for a moment: how would you make one in UDK? It seems simple until you realize that at any moment any one of the 27 cubies making up the larger cube could be in any place, in any orientation. That’s a lot of variability, and nothing that simple constraints can keep track of.
But after untold hours, I managed it:
Because I plan to use this for something, I won’t be releasing code yet. I can tell you, however, that there are a total of 81 InterpActors that make up the cube, along with 26 special actors I made especially for this purpose. Most of the functionality is also handled by triggers and Kismet.
I will also tell you that float imprecision is a massive pain, and I hate how UnrealScript doesn’t have a “fuzzy float == operator” like many other languages so that 259.997 really does equal 260.000.