How do I Affect Z ordering based on Y position?

0 favourites
  • 2 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Hi, Im struggling with a problem that I'd be very grateful for help with.

    In my game flowers (one object) appear at random places within a set area, I am trying to make it so that when a new instance is created it detects if there will be an overlap with an instance of that object that has already been created, check its y-position and then if the new instance has a greater or equal y-position it'll move the new instance to the top in the z order.

    I hope that makes sense?

    Effectively I am looking to make it so that when a new instance of an object is spawned it'll place it either in front of or behind previous instances based on how high up tghe screen they are - giving a sense of depth.

    Everything I've tried so far hasnt worked as Im dealing with instances of the same objects (I can do it if its sorting between different objects!)

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think I actually just got it (or a crude version at least!)

    On create> add sprite.Y to YInstanceVar

    On Sprite overlap + Pick High/Low instance variable > pick Highest from YInstanceVar > Move to Top Layer

    It kinda works

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