reactdev Posted April 23, 2020 Share Posted April 23, 2020 this.map = this.make.tilemap({ key: 'map'}) let tileset = this.map.addTilesetImage('tiles', 'tiles') let terrain = this.map.createDynamicLayer('terrain', tileset).setCollisionByExclusion([]) this.playerSprite = this.physics.add.sprite(200,0,'players',0) this.physics.add.collider(this.playerSprite, terrain) this.cameras.main.startFollow(this.playerSprite) This code has the effect of the player sprite falling through the terrain layer. Why? I've tried using setCollisionByProperty, setCollisionBetween, and setCollision. Nothing works. Using Phaser 3.22. Link to comment Share on other sites More sharing options...
reactdev Posted April 23, 2020 Author Share Posted April 23, 2020 Solved with setCollisionByExclusion([-1]). Apparently by default even empty tiles were colliding, meaning the physics engine basically turns itself off because a physics body was placed inside of a body it is supposed to collide with. Link to comment Share on other sites More sharing options...
Recommended Posts