Explore the world of virtual dice rolling with RNGNeeds' Dice Playground. This sample demonstrates how you can simulate various dice rolls and combinations, from simple 6-sided dice to complex biased rolls. Whether you're looking to create a tabletop game or just want to experiment with probability, the Dice Playground offers a fun and interactive way to dive into the mechanics of randomness.
Inside the /Dice folder, you'll find several
Die Scriptable Objects, such as 1D6, 2D4, etc.
You can modify these to create dice with specific behaviors, or you can create your own Dice by going to Create » RNGNeeds » Dice Playground » Die.
Also in the folder, you'll discover a
Dice Roller Scriptable Object. This handy tool features a special inspector, allowing you to drag your created dice and roll them.
The Dice Roller will display how each die rolled and will sum the rolls as well. You can integrate this system into your own project and start using it.
Just ask the DiceRoller to
.RollDice(), and it will return an
int with the sum of the rolls.
Last but certainly not least, you'll find a DicePlayground scene. This is a deterministic dice roller simulator, designed to work with the Die objects. Enter Play Mode and click the Roll Dice button. The dice will physically roll onto the surface with a predetermined result - you'll see the outcome before they enter the frame.
This is achieved by simulating the physics of the roll, determining which side the simulated dice landed on, then rotating the material so that when the roll happens in real time, the resulting side will end facing up. While this simulation sample goes beyond the reach of RNGNeeds - our plugin merely provides the RNG aspect, or the roll - we felt that a deterministic dice roller example would be a fun and engaging addition.
Pick Counts and Disabled Items - by default, the assigned
1D6 die has only a single enabled item in the list - the side one. This means that the list will only pick that value, if the chances are right - based on its probability.
If the random pick would have selected a disabled item, for example, the side six, the pick would be unsuccessful and would have returned nothing. This is where
Maintain Pick Count feature comes into play.
In the scene, you can control how many dice are rolled with a slider. You can also control whether the selection should respect the desired pick count - by enabling or disabling the Maintain Pick Count toggle. If disabled, the actual number of rolled dice will be lower - just the ones that make it through the selection.