Search Unity

Thin rigidbodies + Continuous Dynamic = stuttery collisions

Discussion in 'Physics' started by dgoyette, Jun 14, 2019.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Is there a known limitation with Unity/PhysX when it it comes to thin objects using Continuous Dynamic collision detection? In my game, objects tend to move pretty fast, so I generally use Continuous Dynamic collision ob rigidbodies unless performance becomes an issue. But for thin objects, this looks really bad.

    Here's a comparison. Here I've created a bunch of "tiles", which are simply 1m by 2m by 0.025m cubes. Add a rigidbody, then duplicate. When using Continuous Speculative, the objects fall and collider nicely:

    ContinuousSpeculative.gif

    However, switch them to Continuous Dynamic, and the behavior is much more jumpy, as though the objects are getting stuck in the air for several frames in a row, then resuming their fall:

    ContinuousDynamic.gif

    Is there something I can do to improve this behavior, aside from just not using Continuous Dynamic in these cases?
     
  2. terresquall

    terresquall

    Joined:
    Mar 2, 2014
    Posts:
    29
    Continuous speculative is better at handling collisions arising from object rotations, which is why it looks smoother in this instance (lots of rotation when the tiles are falling!). Continuous dynamic is generally used for fast-moving objects, while continuous is used to prevent fast moving objects from tunnelling through an object that doesn't move particularly fast (which is what you want, since your tiles aren't moving particularly fast).

    To fix this problem of yours, you might want to write a script that dynamically changes the collision mode between continuous speculative and continuous, so that you get the best of both worlds. Generally, continuous speculative has poorer quality than continuous, but it deals with rotational collisions much better.

    Here's an article talking about all these collision modes in more detail: https://blog.terresquall.com/2019/12/collision-detection-modes-in-unitys-rigidbody-component/
     
    LudiKha likes this.