Dice Not Behaving to Normal Physics
I have created 2 cubes to use as dice.
I drop them from a height with a random rotation.
When they hit the plane collider that I have created as the surface for the dice to fall on to, they will roll around a little and then finally come to a stop. This is when I detect what side is facing up.
The problem is that the dice are not behaving like real dice would.
For example sometimes the dice will land on an edge and the very slowly fall to a face.
Sometimes they will just stay on the edge.
Sometimes they will fall almost all the way to a flat side, but still not quite be all the way down so I can't detect that they have achieved a side.
The physics settings for the game are all default so the gravity setting is -9.81.
The dice have a rigid body on them with these values:
mass: 1 drag: 0 angular drag: 0 use gravity checked is kinematic not checked interpolate: none collision detect: discrete
I think those are the defaults.
I have tried making the mass very large and that did not change how they behaved.
If you throw real dice and they are not spinning around they fall to a side almost instantly. This is the behavior that I would like.
Can someone tell me how to make that happen?
Answer by clickmatch · May 04, 2017 at 05:20 PM
This is an older post, but in case anyone else wants info. Step 1 is apply a physical material to the collider. This allows you to tweak friction and bouncyness. You can also add one to the rolling surface, which makes a big difference, and the phys material can be set for those values to interact.
I also did a script for nudging and kicking stuck die. if it couldn't detect the side, it would return a zero.. and on the update I'd nudge it:
if(side == 0) {
if(attemptCounter < 5) {
Nudge();
} else {
Roll();
}
} else {
etc..
public void Roll() {
isRolling = true;
awaitingResult = true;
rb.AddForce(Random.onUnitSphere * forceAmount, forceMode);
rb.AddTorque(Random.onUnitSphere * torqueAmount, forceMode);
attemptCounter++;
}
public void Nudge() {
isRolling = true;
awaitingResult = true;
rb.AddForce(Random.onUnitSphere * 0.2f, forceMode);
rb.AddTorque(Random.onUnitSphere * 0.2f, forceMode);
attemptCounter++;
}
Answer by Hotshot10101 · May 04, 2017 at 05:26 PM
I ended up doing similar things, but still feel like it doesn't match real world dice very well.
I agree. We did a game here involving that, and it's close, they are satisfied, but it's not as realistic as it could be.
Your answer
![](https://koobas.hobune.stream/wayback/20220612095221im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rolling a 3D Dice: Detect which number faces up? 4 Answers
Mixing physics and path... 0 Answers
Why/How 2d tower of blocks collapse? 0 Answers
cant get raycast to work with tags 1 Answer