Search Unity

How to make a cube fall from the edge when part of it is outside

Discussion in 'Physics' started by CesarOrozco, Sep 22, 2019.

  1. CesarOrozco

    CesarOrozco

    Joined:
    Dec 30, 2016
    Posts:
    14
    Let's assume I have a 1x2x1 cube and it is balanced over an edge, since the weight of the cube is distributed perfectly, it doesn't fall, how to make it fall when part of the cube is over the edge?



    I have tried adding invisible objects to both ends of the cube and then adding another invisible object on the edge so when they collide I change the center of mass of the cube, this seems to work but I think it is overly complex since I have to add that invisible object around all edges of my scene.
     
  2. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    Go the other way: leave the box as it is and just decrease the size of the collider of the floor.

    This, however, will make it look like the box falls through the floor.

    I really don’t think there is an easy way to trick the physics into this behavior. What you could do, however, is to add triggers to the edges and change the center of mass towards the collider that the box hit.

    Note, that you can do this in a script without adding any extra weight by only changing rigidBody.centerOfMass
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    There is many way you could do this.
    Fe already mentioned.

    Indeed shifting CoM is good one.
    Moving collider is another option.
    Or simply add force somewhere on the left of the table, acting downward. This will act as leverage.