[Resolved] How do I make a collision hit just 1 enemy?

0 favourites
  • 5 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Working on a karate platformer, think Kung Fu Master where multiple enemies are approaching the player from both sides...

    When my player kicks, I spawn hitBox sprite overlapping the player's leg, with a 1-frame animation with speed of 60. My logic is:

    - when enemies(family) on collision with hitbox

    - kill enemy

    - destroy hitbox

    I want the kick to only hit one enemy, even if the kick animation and its collision polygon collides with multiple enemies (e.g., when multiple enemies overlap). However it kills all enemies that collide with the hitbox. I even moved the logic to a subevent with a 'trigger once' condition but with the same result.

    Any suggestions on how to make this work, or better logic given the situation?

    Thanks

  • It should hit one enemy, which enemy? It depends on that really.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The one closest to the player probably makes the most sense.

  • There's a system condition pick nearest instance, so you can pick all instances that are overlapping the hitbox which is what you currently have, then you can limit further in a sub event with pick nearest to player.

  • Thanks for the guidance here! Turns out the issue was because multiple hitboxes were spawned during a kick, which is triggered on an animation frame. I used the "trigger once" condition to fix that. I also then used 'overlapping' instead of 'on collision' and it works smoothly. Here's the logic that's working for me in case anyone is interested.

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