I’m having some issues with the collisions on the player and tile. It doesn’t seem to register collisions. I have set the debug to highlight the tiles, and they tiles are highlighted. However, the player sprite just passes through and no collision is detected. All in create()
this.ground = this.map.createStaticLayer('ground', tileset, 0, 0);
this.map.setCollisionByProperty({ collision: true }, true, true, this.ground);
this.player = this.physics.add.sprite(this.map.widthInPixels / 2 , this.map.heightInPixels - 150, 'car');
this.player.setSize(160, 125);
this.player.setScale(0.25);
this.player.setCollideWorldBounds(true);
this.physics.add.collider(this.player, this.ground, this);
I have also added some debug text and tried to do a manual check in the update (is always false):
if(this.physics.collide(this.player, this.ground)) this.hittext.setText('TRUE');
else this.hittext.setText('FALSE');
Like mentioned the tiles set for collision are highlighted with:
this.map.renderDebug(this.debugGraphics, {
tileColor: null, // Non-colliding tiles
collidingTileColor: new Phaser.Display.Color(243, 134, 48, 200), // Colliding tiles
faceColor: new Phaser.Display.Color(40, 39, 37, 255) // Colliding face edges
});
My config is as follows:
let config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 960,
height: 640,
physics: {
default: 'arcade',
arcade: {
gravity: { y: 0 },
debug: true
}
},
scene: [ SplashScene, CarnivalScene, ShootingGallery ]
};
This is a isometric map, so no gravity. I based everything off of https://www.phaser.io/examples/v3/view/game-objects/tilemap/collision/csv-map-arcade-physics
but of course I’m using a tiled map and not csv.
One thing I do notice when inspecting this.ground during debugging, is the layer.collideIndexes.length = 0