Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Dice rolling lands on edge :/

Discussion in 'Physics' started by giggioz, Feb 26, 2019.

  1. giggioz

    giggioz

    Joined:
    May 11, 2017
    Posts:
    52
    I'm trying to implement my own version of a dice roller.

    So far I've reached a decent result, my solution is not very flexible yet but I like the realism of the physics.

    I have an issue, though: sometimes a dice lands on it's edge and it keeps that unnatural position for the rest of the time.

    How can I avoid it?

    I tried to tweak the physics materials, the rigid body simulation, the scale of the dice and the system gravity with no success.

    Maybe I did not find the right mix or maybe I'm missing something.

    I will appreciate any suggestions thanks! xxx.png
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,782
    This is how I would suggest solving it. There are probably other approaches.

    (Singular "dice" is "die.")

    Simulations like this need jitter (random forces applied) or followthrough (continue a recent force even after rest). For every die, on each physics update, keep the last non-zero velocity. If a die spends a short time such as 100ms at zero velocity, but you still can't identify which side is facing up or facing down, then give it a small random impact force in the same direction of that last movement.
     
    giggioz likes this.
  3. Nintynstor

    Nintynstor

    Joined:
    Dec 12, 2022
    Posts:
    2
    It's awesome that you've been working on your own dice roller and aiming for that realistic physics feel. However, I understand the frustration of dice landing on their edges and refusing to budge.
     
  4. taratorit

    taratorit

    Joined:
    May 23, 2023
    Posts:
    1
    The thread is old and I just want to remind you to consider the surface on which the dice are rolling. Are there any imperfections or obstacles that could cause them to land improperly? Smoothing out the surface or providing a more controlled environment might help mitigate those pesky edge landings.
    Oh, and speaking of dice rolling, have you checked out the best free online dice roller? It's a fantastic resource that can provide some insights and inspiration for your dice roller. Head over to flipsimu.com/dice-roller/roll-d12/ to explore their handy tool.
    Keep experimenting, my friend! Even though it's been a while since this thread, I believe in your determination.
     
    Last edited: May 31, 2023