Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Add all physx static collider to dots physics, possible.

Discussion in 'Physics for ECS' started by koirat, May 25, 2021.

  1. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    I would like to move all my static colliders to dots physics for faster raycast and general multithreading calculations. How can it be done ?
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    851
    Assuming you have the Unity.Physics package installed, add a ConvertToEntity script or use subscene conversion(put all gameobjects into a subscene and the whole scene gets converted).

    You should experiment with the samples repo to get a feel of what exactly gets converted and what doesnt. Generally speaking there's a lot of things that flat out don't exist in DOTS so if you rely on your static gameobjects for anything other than a meshrenderer and collider, it may not get converted.
     
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    I'm sorry I was not precise enough.
    I wont to use Physx and DOTS physics at the same time.
    Ideal solution would be to have it at runtime, grab all static colliders and clone them to DOTS physics.
     
  4. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    851
    There's nothing out of the box for this(as conversion was designed as a one way trip) so you will be needing to figure out your own workflow for setting up colliders to duplicate physx data.

    As long as you mean side by side and not interacting with each other(ie cant physx raycast using against a dots collider), sure its doable, question is it worth the hassle of setting things up to do essentially double work with dual physics systems, or would you better be served by choosing one.
    I sort of did this with characters for a short while, but in the end scrapped physx in favor of everything dots as the back and forth wasnt worth it for me personally.
     
  5. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Yeah it's gonna be a manual thing. You need to look at physics shape conversion in DOTS, but also the BuildPhysicsWorld system. After you've done those two, it will be possible for you to do queries only.