How do I hit only hit one target at a time?

0 favourites
  • 6 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hey guys.

    I'm making a game where an arrow hits the targets. It's all very simple, except that sometimes the arrow hits two targets that are close at the same time, I don't want that to happen, I want it to hit only one target. Any idea how to do this?

    thanks!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you using on collision for your even trigger?

    Should be something along the lines of:

    Arrow on collision with Target || Destroy target (Or whatever you want)

    I believe on collision only targets 1 but if it is still hitting 2 targets add another condition:

    Arrow on collision with Target

    Arrow Pick nearest Target || Destroy target (Or whatever you want)

  • Whenever that I was building a fnf game, the destroyed multiple notes destroyed as a problem for me, but I've figured it out by adjusting the hitbox. I don't know if the hitbox is the problem for you if not, then I don't know then

  • grab the closest one isn't working, at least here.

    Targets are tiled circles that move downwards. Sometimes the arrow hits 2, and even if I use the "pick nearest" it destroys both targets. I put a boolean variable on the arrow, for it to deactivate after it hits a target, even so, it destroys two times.

    The only way it worked was:

    1 - when the arrow hits the target, it fixes itself in the center of the target

    2 - then I get the arrows, the ones that are "fixed" are destroyed

    3- the arrows when destroyed, if they are on top of something target, destroy the target too. Everything happens very fast and ends up working out. But it doesn't seem like an elegant solution to me. I don't understand why "pick nearest" doesn't work =/

  • updating you. Before it was like this:

    - ARROW Overlapping another object TARGET

    - PICK NEAREST TARGET (ARROW.X,ARROW.Y)

    I changed to:

    - ARROW On collision with TARGET

    - PICK NEAREST TARGET (ARROW.X,ARROW.Y)

    And apparently it worked =D

  • I would have to see your actual code to try to figure out why it didn’t work with with the Boolean on the arrow.

    But on collision is designed for things like bullets and it only triggers once which makes it easier to work with. I believe you can even remove pick nearest while using it assuming you are destroying the arrow on the collision.

    But if it works that extra call isn’t gonna hurt performance any so no need to worry about it

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