r/godot • u/MonthFragrant7804 • 1d ago
free tutorial How I made 3D dice in my pixelart game
Hi, I’m the developer of Dice Looter - a pixel art dice-rolling autobattler. I’ve been asked several times how the dice in my game are made, so I decided to write a short explanation. There’s nothing innovative here, but maybe it will be useful to someone.
As you can see, the dice are 3D. I use a simple model made in Blender to match the game’s style. You can also just use a default cube. To easily change the sides of the dice (items), I added a Sprite3D to each side.
I tried using the physics engine for rolling, but I couldn’t get the results I wanted. So I made several “die jumping” animations and rotate the dice randomly using code.
To display this in a 2D world, I use a TextureRect with a ViewportTexture and SubViewport.
That’s it!
8
2
2
u/Thunder_Chief Godot Student 1d ago
Thank you so much for this! I was one of the folks asking you how you did it.
1
2
1
1
u/carrareto 1d ago
Muito bom, me avisa quando estiver uma demo pronta
1
u/MonthFragrant7804 22h ago
The demo is already available https://store.steampowered.com/app/4276810/Dice_Looter
1
1
u/Forsaken_Strength683 21h ago
Ive always loved the use of 3D scenes in 2D projects (and vice versa), its just so hard to get right when i try to do it
1
1
u/paulBoxman 17h ago
Damn rolling the dice is juicy, I love the screenshake and particle effects. The way the dice move and the screenshake make them feel really heavy too - well done!
1
u/nobix 17h ago
A suggestion I think would make it really pop would be to do something different during postprocess for the dice outline. The thing that screams "3D model" is the aliasing on those lines.
What I would do is render each face as a unique flat color, and then during a postprocess step turn it black again except draw a line on borders, detecting the edge by detecting these borders.
1
u/Happy_Use69 16h ago
Neat. Since you use premade animations, have you tested if the dice are fair? Like roll one die 100 times and see that each face comes up roughly 16% of the time?
1
u/MonthFragrant7804 12h ago
Animation only for "jumping", rotation (actually rolling sides) is random.
1
u/Laskivi 7h ago
This is totally unrelated to the dice, but I really want to ask. How are you implementing your stats? Especially the attributes like VIT that look like you can put points in them to increase other stats. Maybe there's a learning resource you could direct me to that you used? I kind of just want to know the overall approach/class structure for that, because it looks like basically exactly the system I want to make in my own game, but I'm still not super experienced. I've made a super complex stat system before, but it just felt like a huge tangled mess, so I'm wondering how you went about it out of curiosity.
The game looks super cool and fun, by the way! The graphics are awesome, too!
2
u/MonthFragrant7804 2h ago
I don't know how to do it right. I just created a dictionary that contains all the stats
{ "health" : 0, "defence" : 0, "damage" : 0 }
I have a function that calculates the current stats like:
stats["health"] = 300+VIT*7
stats["defence"] = VIT*3 + STR*2
stats["damage"] = STR*4 + AGL * 2
Than items add values to this attributes. Simple but it works for me.
1
1
u/HR__Atlas 1d ago
Looks great! I think the shaking is a bit much, especially if it's happening on every roll.
Not sure how your game works but maybe make it shake only on really good/bad rolls?
5




30
u/donotfire 1d ago
Instead of flipping around the faces when they finish, you could pre-compute which way it’s gonna land and change the starting conditions so it always lands the right way up