Jumping on enemy hurts player character. (Platformer game)

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • 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.

  • Hi GaoLi,

    The accuracy of collisions is what is causing your problem. If you isolate line 62, when the enemy is changed into an obstacle the player dips into the enemy and floats up. In other words the player health will always be triggered. I've added a line that the player and enemy y pos must be the same to get hurt :)

    Please login to see this attachment.

  • Hi GaoLi,

    The accuracy of collisions is what is causing your problem. If you isolate line 62, when the enemy is changed into an obstacle the player dips into the enemy and floats up. In other words the player health will always be triggered. I've added a line that the player and enemy y pos must be the same to get hurt :)

    Please login to see this attachment.

    Thank you very much. That did indeed help, though now the player character sometimes jumps on the enemy and stays there and the enemy doesn't get hurt. I don't know if it's because of weirdly angled jumps the character can make. This is quite challenging. Thank you still. I would have never been able to figure this out on my own or get this far without the help from the community. Please login to see this attachment.

  • Hi GaoLi,

    Sorry that the example didn't work so well, I must have played with it and forgot to do a last test. It turns out if you get rid of it all together it works seamlessly. Couldn't understand why it was needed in the first place?

    Please login to see this attachment.

  • In the past, I have used the Fall Animation to cause damage to only the enemy.

    Basically, if you put NEGATE Animation Fall is playing + Collides with enemy = Damage to player. ( HURTS PLAYER ) and Animation Fall is Playing + Collides with enemy = KILLS ENEMY.

    This should work for you. Basically, it is like how SUPER MARIO Brothers works.

    You could get specific too by using Direction.

    Like all downward movements cause damage to enemy and any other movement causes damage to player, during a collision.

    Hope this helps.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!