'Odd behaviour in gravity from different directions matter js phaser 3

I'm making a platformer game, in which I have a powerup that lets you fly. On collision, I removed the powerup using powerup.gameObject.destroy() and disabled gravity using player.setIgnoreGravity(true). Now when I touch the powerup from different directions, it produces a different result like shown below. Case 1: Approach from above

Case 2: Approach from side

Here's a minimal example: https://jsfiddle.net/prateek_1/rsoj0h2z/

Any help is greatly appreciated. Thanks!



Solution 1:[1]

Well the code works as it should, here is why:

Scenario 1)
you touch the powerup while not touching the platform (playertouchingground==false) -> no gravity, and the player doesn't fall to the ground. AND because the player is in the air you can't jump.

Scenario 2)
you touch the powerup while touching the platform (playertouchingground==true) -> no gravity, now you can jump, and when you jump you fly away, since nothing is "pulling" the player down.

The question is, what do you want to happen, when the objects collide?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1