I haven’t been able to figure them out for a very long time how to set up collisions

I make a game on Phaser and I have problems, I create collisions in tiles so that when entering the player touches only specially created collisions, but instead the player touches an entire tile, which is why the player cannot get into some places if someone helps here’s a piece of my code

const groundLayer = map.createLayer('ground', groundTileset, 0, 0);

const wallsLayer = map.createLayer('walls', wallsTileset, 0, wallsToNull);
// ...
this.player = this.physics.add.sprite(540, 100, 'player');
this.player.setScale(0.4); 
this.player.setSize(30, 20); 
this.player.setOffset(0, 45); 
wallsLayer.setCollisionFromCollisionGroup(); 
this.physics.add.collider(this.player, wallsLayer);

How to make sure that the player stops not at tiles, but at colliders that are in tiles, so that they block only some part of themselves

setCollisionFromCollisionGroup() is for Matter Physics only.

I used it, but it only checks whether there is a collisions there, and knowing this puts colliders on the entire thile (at least that’s how it works for me)

https://phaser.io/sandbox/3FHqrjdp

1 Like