Jump to content

Dynamic Tilemap Collisions Broken


reactdev
 Share

Recommended Posts

        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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...