Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[Unity 2D] Using rigidbody2d on non-movable (i.e) static objects.

Discussion in 'Getting Started' started by FormianTaskmaster, Aug 11, 2015.

  1. FormianTaskmaster

    FormianTaskmaster

    Joined:
    Aug 11, 2015
    Posts:
    3
    Hi,

    First post here :)

    I'm learning the basics for 2d development and I'm digging into the physics engine. I've read that the recommended use case for rigidbody2d is for 2d objects that are moving, and for static-non movable objects like walls it's best not to put it in it.

    Is there any use case for static objects that benefit from having rigidbodies2d? Like for example, bounciness? I.e. It's not the same bounce for a rubber ball against another rubber wall, than a rubber ball vs "sponge" wall, or hard-flat wall.. etc
     
    Last edited: Aug 11, 2015
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,887
    I'm not positive, but I believe that's what the Physics Material component of the collider would be for. Rigidbodies are expensive, so you want to keep them as limited as possible.

    Edit: Oh, and welcome to the forums. :)
     
  3. FormianTaskmaster

    FormianTaskmaster

    Joined:
    Aug 11, 2015
    Posts:
    3
    Thanks!

    Yeah, my question was more into using RigidBody on a wall (i.e. non moving object). What I understand from what you just said, if I want to make the wall 'rubber-like' I should attach a material to the collider. So, RigidBody2D has nothing to do in that wall, then.
     
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,887
    Correct. Your wall object would have a 2D collider on it, and you should be able to assign a physical material to the Material property of that component. I haven't done any 2D stuff yet, but I figured that's how it works compared to the 3D stuff.

    Rigidbodies should only be on the things that move and are affected by physics, not the things that affect those things, if that makes sense. Colliders are enough to do that part.
     
  5. FormianTaskmaster

    FormianTaskmaster

    Joined:
    Aug 11, 2015
    Posts:
    3
    Alright, thanks!