• he/him

Coder, pun perpetrator
Grumpiness elemental
Hyperbole abuser


Tools programmer
Writer-wannabe
Did translations once upon a time
I contain multitudes


(TurfsterNTE off Twitter)


Trans rights
Black lives matter


Be excellent to each other


UE4/5 Plugins on Itch
nte.itch.io/

vectorpoem
@vectorpoem

Some digital games (assume I'm talking only about those for the rest of this post) with "board game / pen & paper" aesthetics represent die rolls by actually making rigid body physics objects and simulating them tumbling around from an initial (possibly player input determined, possibly not) transform + impulse, and then reading the result for "which face of this object is facing directly up?" to get the outcome. Other games more conventionally pre-calculate the result of the roll in code, and then play a canned animation of the die coming up with that value.

For the latter - at Irrational we called this "emulated" in contrast to the former "simulated", which I assume came from the Looking Glass lexicon - it's very easy to transparently apply any of the usual PnP / board game bonuses and penalties that your mechanics might feature to the result - eg a stat boost turning a straight D6 roll(1, 6) into a roll(1+bonus, 6) or roll() + 1, etc. The result is calculated instantly in code, and the appropriate canned visual is displayed to the player to give them the feeling of having just made the roll. Standard stuff.

What I'm wondering about is how you do this for the former case - for simulated die rolls where the result really is an emergent outcome of the physics sim. If you want to add a +1 bonus of any kind, does that put you back into predetermining the result territory, and faking that it was a real simulated roll for the player? Or do you actually add extra weight to the sides of the die that will produce the intended outcomes? Or do you run a bunch of simulations invisibly behind the scenes in a single frame / spread over a few frames until you get the result you want, and then play that for the player? Or do you somehow calculate what starting transforms and impulses for the die will or won't produce the intended result? And how do you handle any of those if player input is affecting the dice as the roll starts?

This isn't for an actual game I'm working on or anything, it's just a question that stuck in my brain because it didn't seem to have an obvious answer. Would love to hear about it if anyone has tackled this particular problem before!


You must log in to comment.

in reply to @vectorpoem's post:

I may be misunderstanding you, but when you're applying a bonus to a dice-roll in a physical game, you tend to that after that fact as well. It's not like the numbers of the physical die change according to the bonus. This obviously doesn't work when you want the modifiers to be hidden away from the player, but I'm also firmly in the camp of always having this kind of information out in the open.

Seconded.
If i see a d6 roll in a game, i always assume it's supposed to be 1/6 for each face of a die. If you change odds beforehand, i'd feel cheated no matter what (even if it's in my favor).

im speculating at least as much as you but i just wanted to highlight a possibility that you dont mention: simulating a dice roll in a single frame, adding your bonus, and then playing back the roll with the sides modified so number+bonus comes up. i guess that would sort of be a compromise between the two approaches?

In this case, I'd do it the way I do it for real life dicerolls; roll the die, then add the bonus after! For simulations, it means you can't perform special VFX or ceremony early (unless the bonus is so high that the diceroll will always win), but you can instead push harder on the feelings of anticipation that the roll creates.

If you want to fake a physics simulation to give a desired result, you can pick random initial conditions, find out what the result will be, then pick the orientation of the display models relative to the rigid bodies so as to give the desired result, then you can do the physics again for the player. This is assuming the rigid body for a die would be simplified and therefore symmetrical such that whatever side of the rigid body lands facing up can be the desired face of the display model.

Like everyone else commenting here I think even with a emulated roll, I want to see the "natural" results for the roll then any modifications applied afterwards. If what you're after are secret bonuses to nudge the outcome towards success or failure without the player's awareness, it would be much more difficult with simulated rolls as you say.

I worked on a game where we would calculate the roll ahead of time, cuz we needed parity with a server, and then we would do a one-frame physics sim, change the starting rotations to line up with what we "wanted," and then play that back in real time... I guess this is basically a canned animation with extra steps, though! No weighted dice, magnetic boards, or spy gadgets :(

yeah I'm in accordance with the majority here- it feels like you're overcomplicating a solved problem! if it's an additional bonus, then either change the faces of the simulated die to show 2-7 or 1 +1 -6+1 or add the bonus after.

If you're thinking about something different, for example changing the probability of a die landing on a particular face, working this out accurately by changing the centre of mass of the die or changing the shape is extremely nontrivial to do so accurately and will have knock on effects in weird ways.

FOR EXAMPLE, if you have a six sided dice with an approx 16% probability of any one side coming up, and you want to tweak the maths so that a result of 6 is more likely, for a simulated die you could easily just adjust thresholds or RNG so that the probability og 6 is now 25% and the rest are a flat 16% each.
If you try to work this out for a rigid body of 6 sides, and try moving the COM further from the '6' face, you make the '1' face disproportionately less likely to appear relative to the remaining four sides.

if this is the kind of thing you want to mess with, I'd maybe have a good hard think about if 'dice' (simulated or otherwise) is the best means of presenting this information to the player.

just spitballing here, but you could have something like an archery target, and where the arrow hits is your result. bullseye is 6, net ring out is 5, and so on
until outermost ring is 1. The position the arrow strikes is randomised. Bonuses that apply to certain results involves enlarging or reducing the area of the 'rings'. This is much more visually intuitive imo

or maybe you want to have a game where the whole focus is on 'crafting' polyhedra with certain weights and shapes to favour or disfavour certain numbers. "make a die that favours even numbers". Something zachtronics like maybe? idk

I'm rambling lol