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

Question How difficult would it be to manipulate dice physics?

Discussion in 'Physics' started by billygamesinc, Oct 21, 2022.

  1. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    246
    I would like to know if there's a way to manipulate a dice to always land on one side. The dice can bounce and roll as any other dice would, I would like to add external force as well such as wind whenever the dice are airbourne.
     
  2. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    326
    Move the centre of gravity towards the face you want it to rest on (the one opposite the number you want to roll) and add a mesh collider that is spherical except for the face you want it to land on (the one opposite the number you want to roll). Imagine a sphere that just contains the die, but has the base cut off, in the plane of the landing face. You can exclude this collider's layer from interacting with the other dice to prevent anything resting against it once the throw is over.

    By moving the centre of gravity towards the opposite face you encourage the die to land on that face (a classic weighted die), but by adding the rounded collider surface you guarantee that it will roll onto that face. You could probably get away with not making the CoG move, but without it the die will spend more time rocking on the invisible collider, or may even balance on it if you are unlucky.

    Unless you are rolling the die very slowly, no one is likely to notice the additional rounded collider as dice tend to bounce and roll off the corners anyway.
     
  3. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    246
    Thank
    Thank you! Even though this sounds complicated, I will comeback to this once I start polishing if I decide to add the feature. I also didn't add that the ground is not always a flat surface, it is a bowl shape.
     
  4. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    326
    billygamesinc likes this.
  5. chethanv_777

    chethanv_777

    Joined:
    Oct 26, 2022
    Posts:
    6
    Ur answer helped me to get better results, but still not accurate results. 8 out 10 times I roll the dice I got accurate results. But really appreciate and thanks for the answer
     
    billygamesinc likes this.