Component system order

I can’t calculate velocity on current frame in custom script, because sometimes framerate changed and entity move on some distance more then i calculate.

Playcanvas has specific order of calling component system update:
first it calculate dt;
app.update(dt);
for this dt called update for rigidbody component system,
then other commpon call update with this dt
then only called script update with dt

How i can calculate velocity for current frame to stop entity in specific place, with const dt your order can work, but if dt is diffrent on each frame my entity move far from target position;

Using teleport after miss position in my case not acepteble, so i think script system update must called early then rigidbody system update https://github.com/playcanvas/engine/blob/3e36144936e6a95150c532978db3fd4db3160ede/src/framework/components/rigid-body/system.js#L460;

or subscirbe on aplication update event here:


, which is called after all component system update.

In legacy script there was fixedUpdate which is called before all components system update;

for now i change order in this way:

var physicsComponentSystem = this.app.systems.rigidbody;
this.app.systems.remove(physicsComponentSystem.id);
this.app.systems.add(physicsComponentSystem.id, physicsComponentSystem);

is it correct way?