[Solved] Z Ordering and picking a single instance in families...

0 favourites
  • 2 posts
  • Hi! I have this Z-ordering issue which I'm not sure what the problem is exactly but I'm lead to believe it is because I'm not understanding picking correctly? It might be something else, but I'm a hair away from just giving up entirely ::))

    Subscribe to Construct videos now

    As you can see, when player overlaps with collision box below them, the sprite above them becomes above them too, which should not happen.

    Here's my code.

    Every sprite (e.g. the tree, the sign) has a collision box generated at startup at the same time as them. Collision box knows it belongs to a particular sprite because of its "parent" variable which holds the UID of the sprite. Every sprite is in the family fam_sprites.

    So When a player is overlapping the collision box, I ask it to pick the sprite from fam_sprites that the collision box in question belongs to, so that I may move the sprite behind or below the player accordingly,

    But it seems that the picking of fam_sprites doesn't matter as the player moves behind ALL sprites in fam_sprites regardless.

    Am I approaching this wrong? How could I get around this?

    [Edit: I solved this using Z-sorting system function which wasn't here the last time I worked on construct 2... I put all my sprites into another family called Zorder, then every tick set the Zorder family isntance variable to their Y, and then when the player overlaps a collision box, Zsort the items.]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)