Hi there,
I’m a first time Phaser user and to get accuainted with it I’m currently porting a small bomberman clone from libGDX to Phaser 3. I have run into a strage physics behaviour and did not find anything about it online:
When my player diagonally walks into a tilemap wall, it gets teleported back as soon as it reaches the corner see this gif.
Some code snippets:
const config = {
type: Phaser.AUTO,
pixelArt: true,
scale: {
parent: 'xplosive',
mode: Phaser.Scale.FIT,
width: 64,
height: 64,
max: {
width: 640,
height: 640
}
},
backgroundColor: '#cccccc',
scene: {
preload,
create,
update },
physics: {
default: 'arcade',
arcade: { debug: true }
}
};
new Phaser.Game(config);
##############################
const map = this.make.tilemap({ key: 'map' });
const tileset = map.addTilesetImage('brick-sheet', 'tiles');
const undestructibleLayer = map.createStaticLayer('undestructible', tileset, 0, 0);
undestructibleLayer.setCollisionByProperty({ collision: true });
const player = this.physics.add.sprite(4, 4, 'blue');
player.setSize(6, 6, true);
player.setCollideWorldBounds(true);
player.depth = 10;
this.physics.add.collider(player, undestructibleLayer);
const cursors = this.input.keyboard.createCursorKeys();
##########################################################
if (!(left || right)) {
body.setVelocityX(0);
}
else {
body.setVelocityX(left ? -SPEED : SPEED);
}
if (!(up || down)) {
body.setVelocityY(0);
}
else {
body.setVelocityY(up ? -SPEED : SPEED);
}
I like the ECS pattern, so there is an engine and some systems inbetween but the movement code ist pretty simple.
You can try it out here
Or browse through the repo here
Any idea what I might be doing wrong?