Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Can we use DOTS Physics just for spatial queries (without physics)?

Discussion in 'Physics for ECS' started by Mike37, Jul 28, 2022.

  1. Mike37

    Mike37

    Joined:
    Oct 21, 2018
    Posts:
    26
    I have a bunch of AABBs and I'm looking for a solution to speed up queries against them, but I don't actually need any physics simulation. Is this something that could be done easily with Unity Physics? Is there an example anywhere?
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,725
    That is DOTS physics primary purpose - spatial queries, and it is very good at them. Search Unity's github for samples.
     
  3. insectivore

    insectivore

    Joined:
    Apr 30, 2021
    Posts:
    1
    Dots physics says it is stateless

    Stateless
    Modern physics engines maintain large amounts of cached state in order to achieve high performance and simulation robustness. This comes at the cost of added complexity in the simulation pipeline which can be a barrier to modifying code. It also complicates use cases like networking where you may want to roll back and forward physics state. Unity Physics forgoes this caching in favor of simplicity and control.
    Does that mean that the entire bounding volume hierarchy is rebuilt each simulation step? In which case if the number of queries is small compared to the log of the number of volumes (times constant factors) it would be cheaper to check against every volume than to `BuildPhysicsWorld` for one spatial query.