Search Unity

Performance & Moving Static Colliders

Discussion in 'Physics' started by Peacewise, Feb 8, 2015.

  1. Peacewise

    Peacewise

    Joined:
    Feb 27, 2014
    Posts:
    52
    I hear repeatedly that you aren't supposed to move static colliders. Instead, you're supposed to add a rigid body to those objects that also move, because that's much better for performance.

    However, this doesn't appear to be the case for me.
    1) All my movable objects use 2D Colliders (my game is 2D)
    2) NONE of the objects are set to collide with each other or use gravity, etc. I ONLY use colliders to detect touch input.
    3) If I add rigid bodies, performance decreases, presumably because it's doing a bunch of calculation to support functionality I don't need, like colliding bodies & gravity.

    Does this sound right? Should I keep my setup with static colliders that move, or am I doing something bad?

    Thank you,
    Ray
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    if you're adding rigidbodies in 2D ensure it uses isKinematic too, and profile that, since it should skip all the rigidbody extra calculations then. Btw, unity 5 doesn't have this problem or requirement (for Physics, not Physics2D).
     
  3. Peacewise

    Peacewise

    Joined:
    Feb 27, 2014
    Posts:
    52
    Thank you, hippocoder. I hadn't used the "isKinematic" flag.

    In general, testing with the isKinematic flag, I found that performance still decreases with the Ridig Bodies, but only slightly, closer to negligible.

    So far it appears that what I'm doing is not bad for performance.