Search Unity

Question Complex collision geometry, Hybrid ECS

Discussion in 'Entity Component System' started by Fressbrett, Jul 6, 2022.

  1. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    97
    Hi everyone!
    I am currently working on a game that involves dynamic destruction. Currently that is achieved without ECS, by "fracturing" big meshes within the Editor into many small kinematic fragments, which are then activated when something collides. There are some extra pseudo-static calculations and performance optimizations going on, creating quite satisfying dynamic destruction. However, as each fragment is a rigidbody, there can only be a few thousand non-kinematic rigidbodies active at once until the performance impact is noticeable.

    DOTS sounds perfect for this problem, since all of my fragments follow the same logic, and there are a lot of them.

    My scenes have very complex geometry though, with lots of Terrain, Box-, Sphere- and Mesh-Colliders. If possible, I would like to keep those Colliders as GameObjects as well, since lots of my gamelogic besides those Fragment-Collisions depends on MonoBehaviour collisions and rewriting all that won't be feasible.

    Now what I understand is that Entities dont know about the PhysX-Rigidbody-world, which means I would somehow need to "convert" my MonoBehaviour Colliders of my scene to ECS, so that my new Fragment Entities will be able to collide with my scene.

    Is this possible? How big would be the performance impact to practically have two "versions" of the physics-world live at once, one for MonoBehaviours, one for Entities? Is the DOTS physics even made for a lot of complex collision geometry?

    Any feedback would be appreciated, I am really having a hard time finding examples of very complex scenes using DOTS + Entities.
     
    Last edited: Jul 6, 2022
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    Unity DOTS samples on the git has physics demos.
    Check them out.
    One of them I think has convex Hull examples. Also there are examples of Go Rigid Body colldiers conversion to entities colliders.

    I suggest to check them out and see, if they suites your need.
    You can also stress test them.
     
    Fressbrett likes this.