How do I order a picked group of instances based on horizontal position?

0 favourites
  • 3 posts
From the Asset Store
a full game example, menu system, with the first level and a boss, to create a horizontal shooter
  • I feel like this is more obvious than I am making it, but here goes.

    I have a group of instances I have picked based on a few parameters to make sure they are eligible for a certain function. I want to pick only those with the highest or lowest X position (there will almost certainly be several instances at the same X position, which is fine).

    I'm pretty sure I can do this by ordering the list I have made based on X position, but I am completely blanking on how I can accomplish that and could use some help.

  • After you picked some instances, in a sub-event you can do "For each Object order by Object.X" and only process the first instance, after that stop the loop.

    Or, depending on how these instances are positioned, you may be able to use "Pick nearest to" event, for example, to pick the leftmost instance, pick nearest to (-10000, layoutHeight/2) or something similar.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • After you picked some instances, in a sub-event you can do "For each Object order by Object.X" and only process the first instance, after that stop the loop.

    Or, depending on how these instances are positioned, you may be able to use "Pick nearest to" event, for example, to pick the leftmost instance, pick nearest to (-10000, layoutHeight/2) or something similar.

    Perfect! I knew that there was a way to do this, I just didn't know it was nested inside of the "For Each Object (Order)" command. Thanks!

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