body.onFloor true when overlapping with staticGroup body

So I’ve got an issue with my game that I’ve managed to repro in the phaser First Game example, and again in a slight tweak of that example: https://codepen.io/maikthomas/pen/aMaZVE
Essentially the player can jump when overlapping with a staticGroup object.

I’m using body.onFloor() to check whether my sprite can jump, however this is returning true when overlapping with the static object when the player y velocity is downward onFloor

Try to only use staticGroup for the platforms.

stars = this.physics.add.group({ // use group instead of staticGroup
  key: 'star',
  repeat: 11,
  setXY: { x: 12, y: 500, stepX: 70 }
});

stars.children.iterate(function (child) {
  child.setImmovable(); // set it as immovable
  child.body.setAllowGravity(false); // disable gravity
  child.setBounceY(0);

});

this.physics.add.collider(player, platforms);
// this.physics.add.collider(stars, platforms); // this has no use, if the stars do not move
1 Like

I guess it’s worked that way since v3.12. It is a little weird. You could definitely make the case that overlap checks should never set blocked.

Yea, that works great thanks!

@samme I think it’s a valid case, perhaps in the meantime the First Game example could be changed to the above solution too, to not encourage using the wrong type of group / floor check from an early stage.
:man_shrugging:

Cheers both!

I’ve been having that same problem. I agree that overlap should not set blocked or touching. I tried to use Zone to create areas that emit ENTER and EXIT events when my player gets in or out, this areas would allow me to -for-example- trigger a ZOOM OUT effect in the camera when the player reaches certain point in my level, and then zoom back in when he leaves the area. It all works wonderful… but a side effect is that my player can jump in the air while he’s inside these areas cause blocked (or maybe touching, I have to check) is being set by the overlap between the player and the zone.

I’ve disabled these areas for the moment until I have more time to see if I can find a workaround or maybe compile a custom build of phaser with a mod to arcade physics to prevent this.

I would love enter and exit events for overlaps in general. Currently using a lot of flags to track that stuff.
Will yannicks solution not work for your case?

You can use overlap events.
@samme has posted an example in topic #1001

:jawdrop:
Amazing thanks!

1 Like