I am making a game where the dice needs to roll with force all around the table. I need it to be flipping and turning while it is being dropped onto the board as well. I guess what I’m trying to say is it needs to look realistic as to a real dice roll.
1 Answer
1To give it a starting roll, can set angularVelocity. There are some fancy ways, like AddForceAtPosition to simulate pushing up on just one edge, but also simple to just assign angularForce directly.
The axis are always global. So rolling “the way the dice is moving” is tricky with this method. This gives it a mostly “rolling north” spin. Spin is in radians/second (so 6 is about 1 spin/second.):
D1.rigidbody.angularVelocity =
new Vector3( Random.Range(5.0f, 9.0f), // end over end fast
Random.Range(-0.5f, 0.5f), // small y-spin
Random.Range(-1.5f, 1.5f)); // small z-wobble