Sprite jitter (noticable in doc examples)

In this example: Phaser 3 camera example
there is a slight random jitter when moving the sprite. By “jitter” i mean a mini quick teleportation, the sprite stops and teleports quickly, randomly.
It seems to happen more often when you:

  • open the dev tools.
  • click on it to lose the window focus.
  • click back on the game.
  • then move the sprite for a few seconds in only one direction.

But it happens also without doing that (less often, i guess it’s due to panic or deltaHistory)

It occurs when the camera is set to follow a sprite and lerp is not (1,1).
roundPixels true or false doesn’t fix it.

Tested on two computers, chrome and firefox.

It bothers me because in my new game, the player can fall for a long time and it does the same jitter.

1 Like

Did you try editing the physics FPS?

It’s a phaser 3 bug, since it can be seen in the official example with the default config.

this issue wasn’t in phaser 2

PLEASE fix this…

I am creating a top down shooting game like asteroid, all the enemies are jittering like you said when they are coming down :sweat_smile:. I am using arcade physics in my project and the enemy objects are moved by setting a velocity for Y axis.

I found the fix!
it’s not merged in the main phaser file yet but i’m sure it will:

Works great, smooth movement now.

i added it manually to my phaser.min.js

if you have a hard time doing it: search for: a=this._elapsed>=r;
and add this code after: s = e * 0.001; a = true; this._elapsed = 0;

What line does that equate to in phaser.js not min? & what should i change it to?

@samme I haven’t withdrawn the post.

@Thundros
in phaser 3.22 not minified:

between
var willStep = (this._elapsed >= msPerFrame); and for (i = 0; i < bodies.length; i++)

at line 99075, add:
fixedDelta = delta * 0.001; willStep = true; this._elapsed = 0;

this.physics.world.fixedDelta = true;

in Phaser 3.5 this.physics.world.fixedStep = false fixes the jitter,
but it completely ruins the physics consistency in different screen refresh rates. For example, the same jump at the exact same time will produce slightly different trajectories on 60hz screen and 75hz.
Needless to say it’s not an acceptable solution for precise platformer gameplay or precise speed run timed games.
Is there another solution ?

Increasing physics FPS may mitigate this.

Or avoid lerping the camera. :slight_smile:

This is still an issue with the basic camera follow example on the site, kind of a basic feature…
fixedStep, setting physics fps to 120, camera rounding, none of these has any effect.

I’ve had to park my project on v3.24 because this was the last time camera follow worked properly