Hello, everyone,
I'm trying to have my player character jump on enemies to hurt them, but if it runs/walks into them, it will get hurt, like in a normal platformer.
I've managed to get it so that the player character gets hurt and knocked back when walking into an enemy (a light blue box in my prototype) by following almighty zentaco's tutorial and I am currently trying to make it so that if the character jumps on an enemy, the enemy dies.
I've managed to do that too by placing a narrow hitbox underneath the player character. However, when my player character jumps on an enemy, it gets hurt as well. And when it walks into an enemy, sometimes the knock back makes it so that the hitbox collides with the enemy, killing it in the process.
I've included my prototype to show you what I mean. The lines of code in question in my prototype are 56 to 62 and I documented all of my steps as comments.
Does anyone know how I make it so that running into enemies doesn't trigger the hitbox that destroys them and how I can jump on them without getting hurt in the process. Thank you very much.