3D UI Roller (Animated 3D, No Physics)¶
This roller uses the same 3D dice prefab, but animates it in front of the camera like UI.
- No gravity
- No physical collisions (unless you add them yourself)
- Clean, controlled settle onto a chosen result face
Scene setup¶
1) Stage center (where the die ends)¶
Create an empty GameObject in front of the camera:
- assign it to UIDiceRoller3D.stageCenter
2) Assign camera (optional)¶
If targetCamera is not assigned, the roller uses Camera.main.
3) Key parameters¶
stageExtent: how far the die drifts (left-right / up-down)spinTime: how long it spins wildlyspinDegreesPerSec: spin speedsettleTime: how long to rotate into the result facemoveToCenterDuringSettle: whether it recenters during settle
Fixing the “teleport to center” feeling¶
If you increase stageExtent, the die can end far from center at the end of spin.
If settleTime is short, it looks like it teleports to the end position.
Use the Spin Return Bias settings (added to UIDiceRoller3D):
returnToCenterStart(default 0.5): start drifting back toward center in the last half of spinreturnEase: curve controlling how strongly it pulls toward center
One-line UI roll (predetermined)¶
int desired = UnityEngine.Random.Range(1, 7);
uiRoller.Roll(d6Prefab, desired, result =>
{
Debug.Log("UI result: " + result);
});
Next: Dice Prefab & Face Markers.