Can I use DOTS physics and PhysX (built in) physics together?

Im making a game that will be very preformance intensive, having a lot of enemies together, massive maps and the best graphics I can make.

DOTS is obviously needed for this project, buuuuuut, my player movement has a lot of complex things, and I think DOTS physics work different than PhysX, so I would have to remake the player movement.

Can I mix DOTS physics and PhysX?

You can use PhysX but in a sense, that you use GameObjects and RigidBody components.
Then use DOTS for heavy lifting of other calculations.

However PhysX doesenā€™t know about DOTS based physics.
You wont see any collisions, triggers etc. between these two.

But can you describe what you expect from the physics behaviour?
People may will be able to pinpoint the right direction.

I dont expect any behaviour.
Just I want to keep my player movement code, which has sliding, wallrunning, and a joint based grappling gun.
I dont think I can port it to DOTS physics and keep it as it was with PhysX.

If is just for a player, maybe you donā€™t need that part of mechanics on DOTS, if you got complex PhysX solution.
For certain things, you may need entity collider, to use DOTS physics, which is in the same position as GO collider.
It matters, what rest of game does and how mechanics behaves.
You technically could make grappling gun in DOTS physics. It has also joints.
But it may be, you will need duplicate some of colliders, for both PhysX and DOTS physics.
You need to analyzse in your project, what you can afford put on DOTS physics and what must stay on PhysX

I have to add a DOTS collider to the player or a PhysX collider to the things that use DOTS?
Also, the player can still use some DOTS things without the physics?

imo it would most likely be less work to reprogram your character to use dots physics exclusively rather than to go with some hybrid amalgamation of both physx and dots physics

You can use DOTS withouth any physics just fine.
For example just burst and jobs.

Unity 6 now, and I noticed that if I add a cube in a subscene, with a box collider, and press play, unity auto converts the cube to entity.

Hereā€™s the wierd part: If I only have a collider on the box, then my Gameobject character with regular PhysX is colliding with the entity cube, correctly, I can even walk on the entity cube with a regular gameobject capsule collider based character.

However if I add a rigidbody in the authoring cube object in the subscene, then indeed the collision between the character and the entity cube goes away.

is this expected? In the first case where there is collision between the gameobject and the entity, is it ā€˜realā€™ or is it some kind of secondary effect? maybe unity doesnt use DOTS Physics unless a rigidbody is added on the authoring?

I just tried what you described, Liakos, and indeed it does work like this as long as you keep the subscene containing the cube open; once you close it, it seems the cube GameObject stops to exist, only leaving an entity representation of it - and the GameObject character falls through. From my understanding of how ECS works, this means that the behavior you observed would only work in the editor, as subscenes are closed in builds (and if Iā€™m wrong, Iā€™m sure someone will be thrilled to correct me).

Iā€™ll try to clarify.
Let me know if my explanation of how the system works matches your experience.

Every physics authoring component (e.g., Rigidbody, Collider, Joint) within subscenes is baked into an Entity and simulated in Unity Physics. Thatā€™s of course when the com.unity.physics package is present.

Every physics authoring component outside of subscenes is simulated as usual with the regular built-in physics engine, that is, PhysX.

There is one special case:
While any subscene with physics authoring component is open for editing, the entire PhysX simulation everywhere is turned off. It actually is set to ā€œmanual stepping modeā€. So, unless you manually call the Physics.Simulate() function somewhere in your MonoBehaviours, none of the physics authoring components outside of subscenes will be simulated while any subscene is open.

That might explain what you observed here.

1 Like

And to answer the original question, whether DOTS physics (Unity Physics) and built-in physics (PhysX) can be used together:

The answer is yes, as described above.
However, the two physics engines can not interact with each other. So you would for example not be able to collide a Unity Physics rigid body with a PhysX rigid body.

1 Like

We have made a POC were each player have their own instance of our Physx colliders in a DOT physics instance. This way we can easily lag comp. It takes some ram but on the clients only 1x while on the server x numbers or players.

Works pretty well and we will probably move to this solution. Today we move colliders on a special layer and lagcomp doing that. It works but everything is done on the main thread.