Player's bounding box needs to change size but drops through platforms. Please help

Hey All,

I’ll try and be concise.

  • The player’s bounding box changes size in mid-air to facilitate his tuck n roll during his jumping animation.
  • After the flip animation, the player’s bounding box resets to the base size.
  • If the player’s bounding box extends through the platform when it resets to base size, they fall through the platform.

Player’s base bounding box:
image

Player’s mid-air/flip bounding box.

Player falling through on resize:
image

Character jump spritesheet:

Does anyone know a way around this that would work better. At the moment, I have it set so that if the player overlaps the platform, there position jumps to be above that platform, but that feels really clunky.

I’ve tried to change the players origin but that also results in a clunky.

Your help would be much appreciated, thank you.
Moe

You can increase overlapBias in the Arcade Physics config.

1 Like

Doesn’t quite do what I want but it pushed me in a different direction.

Now i resize and reposition the body only if the mid jump size change has occurred.
This means I target only the frames(below) and reposition if the body is just above the platform.
image

It’s not perfect but it’s much smoother.
The code reads something like this:

if (player.anims.currentAnim !== null) {
    if (player.anims.currentAnim.key === 'jump') {
        if (player.anims.currentFrame.index > 3 && player.anims.currentFrame.index < 9) {
            player.body.setSize(30, 40)
            player.body.offset.y = 80-26
            player.anims.play('roll', true)
            player.body.position.y = (platform.y-player.body.height)
        }
    }
}

Than you for your help