Delta position methods for arcade bodies not behaving as expected since 3.17.0

In the game I’m creating I need to be able to distinguish when the player’s sprite is actually moving, or if they’re just being jammed against a wall and standing still. The advice given by this topic is to utilize the sprite body’s delta position methods. After testing them out, I’ve found that they produce consistently incorrect results.

To test this, you can try adding the following code into the update loop in the official collision demonstration linked here:

console.log(`X: ${player.body.deltaX()}\nY: ${player.body.deltaY()}`);

The desired output when standing motionless would be X: 0 Y: 0, as the player sprite is not moving. However, the deltaY() function mistakenly returns 0.06944444444445708, presumably because that is the distance the sprite would have traveled downward had it not been impeded by the ground.

The same behaviour can be observed on the X axis if the floating platform’s spawn coordinates are changed from (400, 400) to (400, 520). If you attempt to run into the platform from the side, deltaX() will return 3, despite the sprite remaining completely still. Interestingly, this does not occur if you try to run into the world boundary on either side of the screen.

It is worth noting that this error only began happening as of Phaser 3.17.0. If you attempt the experiment on 3.16.2 or any earlier revision, the delta position methods will behave as expected and return 0 when the character sprite is not moving. This error must have been introduced at some point during the arcade physics updates beginning in 3.17.

I have attempted to work around this by manually calculating the delta position of the player during the scene’s update function. This began causing nightmarish problems on high refresh rate monitors, I assume due to being detached from the timing of the actual physics updates? I’m currently stuck, and would appreciate any help.

SOLUTION EDIT:
Thanks to some help from Rich over on the Phaser discord server, I was directed towards a viable solution. The current best way to solve this is to manually calculate it during the scene’s postupdate event. Adding the following listener will produce the desired result:

this.events.on('postupdate', () => {  
        dx = player.body.position.x - player.body.prev.x
        dy = player.body.position.y - player.body.prev.y
        console.log(`X: ${dx}\nY: ${dy}`);
    });

I believe the delta values used for resolving collisions, so that may be expected (although undesired).

You can look at velocity or newVelocity (which is actually a per-step delta, despite the name).