How do I determine sprite overlapping with zIndex? (SOLVED)

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hello dop2000,

    First off, I just want to say that your knowledge of Construct 3 is incredible! I’m always learning from your posts and trying to understand even a fraction of the things you do.

    That said, I’m still a bit confused about the picking suggestion above. I’ve built several fairly complex levels, and my simulation code plays through them 1,000 times (in less than 2 seconds!). I tried implementing your suggestion as well as the approach shown in my screenshot, but I’m getting the same results either way.

    I absolutely trust your expertise (after all, you came up with this approach in the first place! Even the best AI models couldn’t figure it out when I tried asking them), so I'm implementing your suggestion I'm just trying to understand the whole fam_cards vs spr_card stuff.

    Speaking of AI, I asked ChatGPT’s GPT-4o model about this, and here’s what it said:

    In a family with only one object type (in your case, spr_card is the only member of fam_cards), using “Pick spr_card by …” and “Pick fam_cards by …” will behave the same way in practice. That’s because there’s effectively no difference between the single sprite and its family—Construct will end up filtering the same set of instances regardless of which name you use.

    Where it does make a difference is if there were multiple object types in fam_cards. In that case, picking via the family name (fam_cards) would include all objects in the family, whereas picking by a specific member (spr_card) would only apply conditions to that one type. But if the family consists of just a single sprite, they are functionally identical.

    In short: If there’s only one member in the family, both picking methods yield the same result. Using spr_card instead of fam_cards isn’t wrong—it’s just more common to use “Pick fam_cards…” when filtering the entire family.

    Does this align with your understanding? Or is there another nuance I might be missing?

    Thanks again for all your help—I really appreciate your time and expertise!

  • I tried implementing your suggestion as well as the approach shown in my screenshot, but I’m getting the same results either way.

    Maybe you haven't encountered the situation when your code would fail.

    ChatGPT gave you the right answer, but to the wrong question :)

    I made a demo which should explain my point:

    dropbox.com/scl/fi/9smxavmssevbkoaf9vx41/CardPicking.c3p

    By the way, I tried asking Grok and ChatGPT the same tricky questions about C3 and Grok appears to be smarter.

  • Thanks, dop2000

    My code has an extra event and it actually makes your first example work. I'm not sure why...

    + System: For each CardFamily order by CardFamily.ZIndex ascending

    ----+ System: For each Card

    --------+ Card: Is overlapping CardFamily

    --------+ System: Card.ZIndex>CardFamily.ZIndex

    ---------> CardFamily: Set animation frame to 1

    Here's my code now and it seems to be working perfectly. Do you see any issues?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, yes, if you have two nested For Each loops, then you can use "System evaluate expression". Because inside of these loops you already have a single instance of Cards and a single instance of CardFamily picked.

    Here's my code now and it seems to be working perfectly. Do you see any issues?

    It looks good to me!

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