Infinite bouncing not working in Phaser 2.20

I just updated an old game from 2.16 to 2.20 and I noticed my rabbits are not jumping forever.
After they are created they stop bouncing and just stay on the ground. This didn’t happen in 2.16 and I would like to know how I can prevent local gravity from affecting my rabbits’ jumps.
Here is the Bunny class

class Bunny extends Phaser.Sprite {
	constructor(x, y) {
		x *= 16;
		y *= 16;
		super();
		Phaser.Sprite.call(this, game, x, y, 'bunny', 'run-1');
		this.anchor.setTo(0.5);
		game.physics.arcade.enable(this);
		this.body.gravity.y = 500;
		this.body.setSize(28, 28, 11, 20);
		this.body.collideWorldBounds = true;
		//add animations
		this.animations.add('idle', Phaser.Animation.generateFrameNames('run-', 1, 1, '', 0), 5, true);
		this.animations.add('fall', Phaser.Animation.generateFrameNames('run-', 2, 2, '', 0), 5, true); 	
		this.animations.add('jump', Phaser.Animation.generateFrameNames('run-', 3, 3, '', 0), 5, true);
		this.body.velocity.x = game.rnd.pick([0,20,50]) * game.rnd.pick([1,-1]);
		this.body.bounce.setTo(1);
		this.kind = 'bunny';
		this.size = 1;
		this.scale.setTo(this.size);
		this.boss = false;
		this.health = 1;
		globalMap.enemies.add(this);
	}
	update() {
		if (this.body.velocity.x > 0) {
			this.scale.x = this.size;
		} else {
			this.scale.x = -this.size;
		}
		if (this.body.onFloor()) {
			this.animations.play('idle');
			if (this.boss) game.camera.shake(0.05,100);
		} else if (this.body.velocity.y < 0) {
			this.animations.play('jump');
		} else if (this.body.velocity.y > 0) {
			this.animations.play('fall');
		}
	}
}

They start bouncing and then stop later? They stop all of a sudden or gradually?

they stop gradually (because of gravity i think)

Hard to say what’s happening.

Total gravity is the sum of body.gravity and physics world gravity.

ye i know.
but the world’s gravity is zero by default in arcade physics.
the sprites are only influenced by local gravity.

i write sprite.body.gravity.y = 500 and they
fall.
and if i write sprite.bounce.setTo(1,1) they has to bounce forever (in 2.16)

idk what is different in 2.20

I’m not sure what it could be. The game loop timing changed in v2.17, but I can’t think of any Arcade Physics changes.

i ran the pen and i waited up to 10 minutes

The same thing happened as in my game.

The body simply begins to slow down until its velocity.y becomes 0. idk why

It is important to mention that my game is for mobile and has a very small 280x128 canvas size.
I don’t have any world gravitation and the Bunny class doesn’t have YSpeed modifiers.

I feel like my only solution will be to go back to 2.16 and start creating optimizations to make it run at 60FPS in that version.

But it was very difficult for me. I couldn’t get more than 45FPS so I updated to 2.20 and then i had that problem with the rabbits.

(sorry if bad English)

I see. :frowning:

Add (in a game state):

this.game.forceSingleUpdate = false;

Thanks a lot! I downgraded back to 2.16 and it runs at 60FPS with Phaser.CANVAS on mobile without any problems.
Version 2.16 is my favorite version of all Phaser versions.
I’m glad I can still use it even in 2024.

Another question: What is GameConfig.forceSingleRender used for?

I don’t think forceSingleRender = true would be commonly used. Only with forceSingleUpdate = false and you needed you do extra rendering somehow.

okey thanks @samme