How to destroy enemy by the player jumping over its head ?

0 favourites
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Hi all,

    In my platformer game, I've some enemies who moves vertically from top to bottom and I want that the player should be able to kill them by jumping over their heads, but if the player touches the body of the enemy the player should die.

    I tried to implement it the following way:

    But it's not working perfectly. Most of the times the player would not die if it touches the body of the enemy and many of the times the enemy won't die if the player touches its head.

    Can you please help me on this? Where could I be wrong?

  • I would make an invisible collision sprite that follows the enemy around above their heads. Put it in a container with the enemy. If player overlaps that kill sprite for more than say 0.25 seconds destroy the enemy.. that's the easiest way I can think of doing it.

  • actually make the sprite narrow enough and center it over the enemy and you dont even need a delay really, since they technically have to be like halfway over the head of the enemy to kill it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh wait you want the enemy to die when you land on it? Like a Goomba / mario enemy? You mentioned you want to kill it when you jump "Over" it so i ran with that. Sorry.

  • In Mario, kill versus death when the player touches an enemy is decided by whether the player is falling or not.

  • I would make an invisible collision sprite that follows the enemy around above their heads. Put it in a container with the enemy. If player overlaps that kill sprite for more than say 0.25 seconds destroy the enemy.. that's the easiest way I can think of doing it.

    Just make a small sprite sticked on the enemy's head, whenever your character touch the sprite the enemy dies

  • One of the things I love about Construct2 is you're able to test for overlaps at an offset. That way you don't actually need a separate object for collision testing purposes.

  • Is that .capx are you looking?

  • I would make an invisible collision sprite that follows the enemy around above their heads. Put it in a container with the enemy. If player overlaps that kill sprite for more than say 0.25 seconds destroy the enemy.. that's the easiest way I can think of doing it.

    actually make the sprite narrow enough and center it over the enemy and you dont even need a delay really, since they technically have to be like halfway over the head of the enemy to kill it.

    Thanks a lot, but yes..that didn't work because I wanted to kill the player if it touches the enemy elsewhere than head. Appreciate your help : )

    In Mario, kill versus death when the player touches an enemy is decided by whether the player is falling or not.

    I tried that but sometimes its falling and touches the enemy on its side instead of head, so it didn't work well.

    One of the things I love about Construct2 is you're able to test for overlaps at an offset. That way you don't actually need a separate object for collision testing purposes.

    It didn't work as expected.

    Is that .capx are you looking?

    That capx is from the new beta verion.. I've the r168 version currently, so didn't try : ( but thanks!

    Just make a small sprite sticked on the enemy's head, whenever your character touch the sprite the enemy dies

    Perfect! Worked like a charm. Thanks a ton!

    I created another sprite (just as the way described) but instead of putting it in a container with the object, I pinned it to the object. That made it work perfectly.

    Thanks a lot everyone

  • To create a mario like effect, I want to add a bounce off effect when the player touches the enemy's head. I tried setting simulate jump to the player when it touches the pinned sprite on the enemy's head, but that is not making the player jump

    Any solution?

  • hi,

    search the forum befor post

    already posted here

    do it easy by adding:

    Event:

    YourSprite..> falling (on falling)

    Action:

    YouSprite...>Destroy

  • you might find your answer in this tutorial

    https://www.scirra.com/tutorials/789/si ... ial-part-3

  • Thanks

  • I'm offended, thanks

  • To create a mario like effect, I want to add a bounce off effect when the player touches the enemy's head. I tried setting simulate jump to the player when it touches the pinned sprite on the enemy's head, but that is not making the player jump

    Any solution?

    The jump built in works only if the player is on the ground, to do a bounce, use instead:

    Set vector Y (set it to a negative value, for exemple, the basic jump is equivalent to set vector y to -self.platform.JumpStrength)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)