Animation Driven Collider Cast/Overlap Queries

I’m trying to dig into the current Unity Physics implementation and one step I’m stumbling on how to do ad hoc queries for a fighting game. Before DOTS/ECS, we used to just run Physics.OverlapSphere/OverlapBox/SphereCast/BoxCast based on the animation values for a character. However, it seems like in Unity Physics, a immutable collider needs to be allocated for every one of these operations. For some of these cases, it’s common to see the size or geometry of these queries change frame to frame in some of our animations. Is the only way to do this in DOTS/ECS to allocate a new collider in a job, query the physics world, then instantly dispose of it? or is there a simpler method for doing this?

In a similar vein, we also have a custom defined convex hull for normal physics interactions for the characters, and would like to manipulate it’s shape in a similar animation driven way (vertex locations being defined by animations). Is this to be handled in the same way?

Unrelated, Is there a way to make Build/StepPhysicsWorld go wide? Currently, it has a large overhead of 2-4ms per simulation step on a simple world with only 4 dynamic bodies and runs entirely on the main thread, and I’d like to be able to run this simulation in a deterministic rollback simulation where this simulation may be invoked upwards of 60 to 120 times in one go.

Update: it definitely seems like creating colliders inside jobs is not a viable strategy. I’m getting all sorts of safety check failures upon launching the job. I’ll try preallocating the to-be-quered colliders instead and disposing of them as the frame closes.

6200420--680414--upload_2020-8-13_16-55-34.png

Nevermind, looked at the docs and it seems like the provided ColliderCast works out more easily than I thought.

Strangely enough the examples don’t seem to Dispose the BlobAssetReference once it’s done with it.

1 Like

Yeah we’ve already noticed that, we will fix the fact it’s not disposed. Thanks!