Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Stacked RigidBody2Ds don't shift when bottom one is moved

Discussion in 'Physics' started by Mr-Men, Oct 14, 2018.

  1. Mr-Men

    Mr-Men

    Joined:
    Feb 18, 2014
    Posts:
    13
    I've got 2 boxes (2D, so squares), each with a RigidBody2D and a BoxCollider2D. Both have a physics material that has a friction of 1, and a bounce of 0. Both have a mass of 1, gravity scale of 1 and linear and angular drag of 0.5.

    When I stack them, and click and drag the bottom box side to side, the top box doesn't move. It's as if there's no friction at all between the 2 GameObjects. I've played round with the RigidBody2D's drag values and the friction value of the Physics material, but there's no change in behaviour.

    I don't want to create a joint between the two, because it's possible to click and drag the top box, in which case the bottom box should move independently.

    Does anyone have any idea on what's causing the top box to not move, or how to overcome it?
     
  2. jvggp

    jvggp

    Joined:
    Jul 8, 2018
    Posts:
    29
    If you move in the Editor so the #scene window it doesn't work.
    Move it by script.
     
  3. Mr-Men

    Mr-Men

    Joined:
    Feb 18, 2014
    Posts:
    13
    I'm not clear on what you mean. This behaviour occurs when I'm running the game from an executable. The click and drag is via a script.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    1,447
    Sounds like your "dragging" isn't actually dragging, it's just repositioning the bodies i.e. teleporting them from position to position. If that's the case then you shouldn't be surprised there's no friction. For friction to apply the body has to be moving through space. Using Rigidbody2D.MovePosition or adding forces, setting velocity is the way to go.