Problems with floor physics

Newbie alert!
I’m writing because I’m having a lot of issues creating the map of my game. I have a map made of two png layers, one for the bg and one for the floor.
I’ve loaded the floor png as an image and then I’ve added it to the game as tileSprite

this.floor = this.add.tileSprite(0, 508, 764, 65, 'floor').setOrigin(1);

then I’ve created the collider with the player

    this.physics.add.collider(this.floor, this.player);

I wanted to use the onFloor() method to check if my player was on the floor, but even if it is on the ground the output is false

this is already in the examples? have you checked it already?

Hi,

The reason it’s not working is due to the tilesprite not having physics attached.

I’m not sure if this will work but I found some information from this link:

The suggested method:
this.floor = this.add.tileSprite(0, 508, 764, 65, 'floor').setOrigin(1);
this.physics.add.existing(this.floor);

Hopefully that should work :slight_smile:

1 Like

https://labs.phaser.io/view.html?src=src\physics\arcade\add%20body%20to%20tilesprite.js