3D World Roller (Physics)¶
Use this when you want real physical dice: they bounce, collide, settle, and the result is read from the top face.
Scene setup¶
1) Dice prefab requirements¶
Dicecomponent (stores face markers / max faces)Rigidbody- A
Collider(MeshCollider/BoxCollider/etc.) - Face markers (see Setup Guides → Dice Prefab & Face Markers)
2) Tray / arena¶
Create a tray with colliders: - floor - walls
Add:
- spawnPoint transform inside the tray
- optional trayCenter transform (used to aim throws inward)
3) Add the roller component¶
Create an empty GameObject, add your physics roller (example class: PhysicsDiceRoller3D), and assign:
spawnPointtrayCenter(optional but recommended)- impulse + torque ranges (feel)
- settle detection thresholds (when result is read)
One-line roll¶
roller.Roll(d20Prefab, result =>
{
Debug.Log("Result: " + result);
});
Notes on correctness¶
World rolls are not predetermined. The roller waits until the die is stable, then reads the top face. To avoid rare “early read” issues, use a confirm window (N FixedUpdate frames where the top face remains unchanged).
Next: 3D UI Roller.