Hi, I’m experimenting with writing a MonoBehaviour wrapper around Unity Physics for the purpose of integrating it with MB-based networking engines (specifically Photon Fusion). This has been fairly straightforward to do by reverse engineering the Unity Physics ECS systems and I have made a functional prototype.
I am now running into some major performance issues. I expected that the overall system would perform worse than the ECS version, but here I am just profiling Unity.Physics.Simulation.StepImmediate (so none of my code) and it’s significantly slower than PhysX.
My current setup is 5x5x5 (125) cubes stacked with 5 solver iterations and SyncCollisionWorld=true (dt is 0.02, but that shouldn’t really matter). On my i7-10700K I stopwatch it at ~10ms when they’re all stacked. With PhysX, I time Physics.Simulate() at 0.25ms…and Physics.Simulate() encapsulates more than just running the sim step (I use a script to force all the RBs awake, as ofc sleeping is a major perf gain for PhysX over UPhysics).
This seems pretty out of wack with my I expected. I’d like to sit down and build a similar test comparing with an immediate step using ECS, but I haven’t worked with Unity ECS enough to be able to do this and confidently get the numbers correct, so I figured I’d ask here for opinions. Note as stated above I do understand any MB wrapper will likely be slower than the ECS one, but my assumption is that once the data is initialized and sent to U Physics it is no longer relevant where it came from.
Thanks for any direction.