Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(+1)

Woah, talk about a quick reply! However, I meant more in the technical sense. There's got to be a way to write a function that takes the die's global rotation and spits out which number is at the bottom, but I couldn't for the life of me write it.

(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.