Selecting only one object when colliding with many

0 favourites
  • 4 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Hello,

    I'm currently coding a script for my platformer game where when the players' hitbox collides with a box and he presses the action key, he'll be able to pick it up.

    The problem however is that there will be cases where his hitbox will be overlapping multiple boxes, and in those cases I'd like to know how I could select - for instance - only the bottommost box?

    Comments and ideas would be much appreciated. :-)

  • I would just do a pick nearest object.

    But you could also find the one with the lowest IID, it would mean it was the first to spawn.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply,

    I can't get the "nearest object" case to work.

    I did the following:

    1. If player hitbox overlaps box.

    2. If player presses D && Trigger once while true

    3. Pick nearest box to hitbox

    4. Destroy box.

    The problem is that it does not destroy one box. It destroys all boxes that are touching the player hitbox simultaneously.

    Can this be fixed somehow?

    Again, I only want to pick ONE box at a time.

    Thanks.

  • Nevermind, I accidently made an error in the event editor.

    It works. Thanks! :-)

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