Wow! That's really interesting, I had a feeling it was something to do with toggling layers but I couldn't put it all together myself. Really impressive. For my game, I used Unity and kept track of the object rotation and original face direction vector. Each time you move, it updates 6 vector variables based on the new rotation, where each vector corresponds to a side. To check to see if a certain side is face up, I simply just check to see if the face vector is equal to Vector3.up, or (0, 1, 0). I tried to keep it as simple as possible and this solution works pretty well. I hope that makes sense haha.