Help with Mario-style jump mechanics

Two simple solutions for your two glitches. Somewhat based on assumptions:


First glitch: Let the enemy have an invulnerability phase, right after he has taken damage. I assume that the cause of reoccuring damage is, that the “jump collision box” is still in contact with the enemy, when the player spams the jump button again. Letting the enemy have an invulnerability phase (like 0.2 seconds) ensures that the player has jumped away by then.


Second glitch: might be caused by the fact, that slight irregularities in tick timing and your jump animation, result in the “collision capsule” colliding with the enemy (making the player take damage), even when the “jump collision box” already collides with the enemy (which should propel the player away from the enemy).

The solution should be similar to the one for the first glitch: make the player invulnerable to the last enemy he damaged. way, you can even move the two collision capsules closer together.


As a side-note: maybe make the “jump collision box” smaller as the “collision capsule”. would ensure, that the damaging “jump collision box” does not collide when you run head-first into an enemy.

I hope was helpful and not too long winded