Issues with physics velocity in ECS

I’m trying the following thing.

  • empty scene
  • add a Cube, remove BoxCollider
  • add PhysicsBody, set initial velocity to (1,0,0)
  • add PhysicsShape
  • add ConvertToEntity

At first it seems to work correctly but changing the fixed timestep in project settings doesn’t work correctly. The cube no longer moves 1 unit per second if I change that.

Also if my frames rate drops to say 20fps I can clearly see that my cube moves way slower.

Are these know work in progress issues or I’m I doing something wrong?

editor: 2019.1.6f1
entities: 0.0.12
unity physics: 0.1.0

Best, Hu

Aha!

I had this exact same issue as I posted here: Unity Physics Discussion page-10#post-4618039

For some reason velocity seems to be affected by time even though it should be defined in units per second

Yeah, my repro is extreme simple. I’ll assume it’s a known issue and it will be refactored at some point. Anyway, I’m not close to finishing my game anyway so I can wait.

Unity Physics is framerate dependent atm, they run simulation with assumption you got 0.02 fixed deltatime but they actually run it once per each update afaik. This causes builds to have absurdly fast physics unless you lock the update speed with vsync etc.

Afaik this happened because of the SimulationGroup change in Entities, they’ll fix it eventually.

There is an example of implementing a fixed time step in the Entity Samples. You have to disable the world update and run it on a MonoBehavior FixedUpdate instead.

Any timeframe when this will be fixed or where i can find the example? :slight_smile:

The example is in the ECS samples on github @Cell-i-Zenit

Relevant file: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/Samples/Assets/Advanced/FixedTimestepWorkaround/FixedTimestepUpdater.cs

But obviously this will not work as is with Unity Physics. This post from PhilSA has workaround snippet but last time I checked, it didn’t work properly anymore (like it did with the first Unity Physics package), not sure if I’ve tested it with the latest release or if it broke on the second physics package version.