How do you generate contacts in DOTS Physics?

It is mentioned here: that contacts can be generated in the Unity.Physics.SimulationCallbacks.Phase.PostCreateContacts phase.
How is this done?

I am trying to create my own wheel collider and I thought it would be a better idea to generate contacts than apply impulses like the samples :)

Hey, adding contacts is not currently supported, sorry about that, documentation is a bit out of date. We are trying to think of the best way to implement this, but unfortunately it has a lot of implications to the rest of the physics pipeline and we need to be really careful. This is the documentation for the latest version of the physics package. Which version are you using?

I can imagine it does :)
It opens up for quite amazing stuff though so I'm really rooting for you! (not that it necessarily helps you much but still... :) )

I realize now I was looking at some old documentation yes...

So I guess at this time it would be quite hard to implement a wheel collider then, right? My idea was that I would create a wheel collider that generates contacts so that the solver can handle them rather than using raycasts as in the samples. Otherwise I guess there will always be pretty strange behaviour when the static friction should make objects come to rest, right? Or am I missing some way to approach this?

Thanks for rooting, it certainly helps! :)

Regarding the wheel collider, I guess there is no easy way to do it with current options.

Assuming you want to do a query (ray cast or collider cast) and then let some solver take care of it, maybe (just maybe) you can take a look at the SimplexSolver. Character controller does something similar - query the world, collect hits and convert them to constraints (the way it likes it), and calls SimplexSolver.Solve() to get a new velocity. Not sure if that's enough, could be. It definitely doesn't need to use impulse applying. Let me know if it feels right!

In the meantime, I will (once again) think about adding the contacts to the pipeline.

1 Like

Ok sounds like a good idea. Maybe I will just wait until out of preview instead, this is not a critical task at all. Just playing around a bit with physics + netcode to get a hang of how things will work in the future.

I really like where all of this is going, keep up the good work!

1 Like

Also, thanks for taking the time to answer!

1 Like