Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Non-convex Physics Slow Down

Discussion in 'Physics' started by billwaahau, Aug 26, 2023.

  1. billwaahau

    billwaahau

    Joined:
    Jan 14, 2017
    Posts:
    5
    Hi, I am experimenting with non-convex mesh collider physics. For some reason, the game slows down a lot when it gets to the concave parts... I guess Unity has to do a lot more calculations... How to fix this? I am trying to avoid making a bunch of smaller colliders. Thanks

    Convex Body Slowdown.gif
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,977
    Don't avoid making a bunch of simple colliders. The system is highly optimized for them.
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,796
    No need, look at the profiler. If it's anything, it's PhysX taking time although the above looks wrong and it's simply the movement slowing not the time-taken?
     
  4. billwaahau

    billwaahau

    Joined:
    Jan 14, 2017
    Posts:
    5
    Ah, I am actually trying to load a 3D model in real time, so wouldn't be possible to make new colliders in real time
     
  5. billwaahau

    billwaahau

    Joined:
    Jan 14, 2017
    Posts:
    5
    Hmmm interesting, I actually tried multiple angles, it always slow down when it gets to those concave edges, like stairs roo
     
  6. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,716
    There should be no difference for these edges, since a concave mesh collider is usually just a bunch of triangles sitting in a spatial partitioning structure (possibly a tree of some kind, like a kd-tree or a BVH). Concave regions are treated no different from convex ones.

    Make sure your geometry doesn't do anything weird near these edges, like many small sliver triangles or a ton of overlapping edges or other non-manifold-like formations.