Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

I basically stored 6 numbers in an array, one corresponding to each colour, and each position in the array corresponding to a face, and whenever the player moved I modified the elements of the array such that they reflected the new rotation. I don't know if this is the best way to do it, but that is what I went with during the jam. Then to find out what number to print, just access the number at the position in the array corresponding to the bottom face.


Now that I think of it, I think it might be possible to get the rotation of the cube as a quaternion, and check against a list of rotations to see which face is face down, but that's just an idea, not sure whether it would work.

(+1)

Thank you! I thought of a similar system, but then I got side-tracked when I realized the face-down number could have 4 different rotations depending on the cube's state (0 degrees, 90, 180, and 270), and that led to the project's doom. In hindsight, I should've gone for the simple implementation for the jam and then expanded it if necessary.

Anyway, thanks for your time, and once more, good job on the jam!

I answered in the comment above: https://itch.io/post/6346372

(1 edit) (+1)

It would work. I implemented dice rotation and face identification with Unity quaternions. The only characteristic each number (1-6) has is it's side normal. No tricky unwrapping and no careful permutation consideration necessary.

When I want to get a face A (e.g. face (0, -1, 0)), I [temp-]rotate all normals with the current quaternion, dot product all with a A and look which one equals 1

(+1)

Thanks, that was quite informative.