Phaser 3 How To Prevent Sprites Overlapping And Tunnelling

Stephen Garside | Wed 15 Apr 20 > 1 min read

Phaser 3 has great collision detection out of the box, but you may experience 'sprite tunnelling' or sprite overlapping issues when two or more sprites collide. If your intention is to have colliding sprites rebound from each other rather than overlap then you will at some point experience issues where sprites tunnel into each other rather than rebound as intended.

A quick and easy way to help prevent this is to set the Frames Per Second or FPS value for your scene to 120 e.g.

this.physics.world.setFPS(120);

I have also found that combining this with a bounce factor on each colliding sprite type to work a treat:

this.body.setBounce(1);

Suffering from Phaser 3 sprite overlap or tunnelling issues during collision? this could help...

Sprite Overlap And Tunelling In Phaser 3

Leave Your Comments...