This.player.body.blocked.down but work for dynamic bodies

I am creating a fighting game and i want the player to jump when the players body is touching down. I am currently using if (this.keys.w.isDown && this.player.body.touching.down) { player.setVelocityY(100) } but the problem with this is that it thinks that the players body is touching when it is in fact overlapping with something else. this means that when the player is overlapping with player2 then they can both jump at the same time and go super high. I tried making a variable that is only true when the two players are overlapping but that is not good for gameplay because the player will not be able to jump when it is in fact touching down but also touching player2. I am very confused and I would like to find a new line of code that detects the players body as touching down when it is touching only the things that it collides with. tldr, i need to find a line of code like player.body.touching.down but doesnt identify as touching something when it is overlapping with something.

@yannick I saw that you had a simmilar question to me a few years ago and I was wondering if you could help me?

If the ground is a static body then you can use the player’s body.onFloor() or body.blocked.down.

If not then you’ll need to keep your own playerOnGround variable, set it in a collision callback, then check and clear it in update().

thanks a lot samme, for some reason the idea of a variable did not come to mind!