How do I arrange z-order of multiple objects by Y

0 favourites
  • 3 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Soo, this may be more complex than I am ready for but I was wondering if there's anyway to - with the event system - make it so that every tick a given instance of an object arranges its z-order in relation to the height of another object?

    ie. Say you have a top-down rpg and you have lot's of different instances of a tree object and you want it so that if the player object's Y coordinate is less than that of an instance of the tree object than the player object will be sent behind that instance of the tree object in the Z-Order.

    I tried a few variations on something like this...:

    Every Tick

    -->Tree | [Y>Player.Y] || Player|Move Behind Tree

    -->System | Else || Player|Move In Front Tree

    ... However having the different Tree instances at different heights the Z-order of the seperate instances got mixed up as the player object moved above and below the trees.

    I made a gif of the layout to try to show the problems I'm having

    In this instance the origin point on both the player and the Tree's are set to middle-bottom. fyi the cross-hair in the middle is just the mouse cursor that I didn't move out of the way.

    Seem's like the Trees "Y" in the condition is being calculated as the Y coordinate of the Lowest Tree and is not running the event individually for every instance? Maybe...? I say this because (ignoring the z-order reshuffling of the trees in relation to each other) the effect I'm after only works as intended with the lowest tree.

    I'm very new at this btw so idk; is there an easy way to achieve this that I'm missing?

    My CapX file

  • I guess I would use something like:

    player is overlapping tree

    -- tree compare Y > player.y

    player move to object behind tree

    -- else

    player move to object in front of tree

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I guess I would use something like:

    player is overlapping tree

    -- tree compare Y > player.y

    > player move to object behind tree

    -- else

    > player move to object in front of tree

    I guess the way I formatted it in my original post was a bit confusing maybe but that's pretty much exactly what I did except I had the top condition as 'every tick' instead of 'player is overlapping tree', not sure if that would make any difference but I'll give it a try.

    EDIT: It worked! Thank you! I'm think I'm still getting my head around why it didn't work the first way but I'm guessing it's something like if the top condition is every tick it won't run the event individually for every instance where as in your solution the tree.Y and the tree to move behing is assumed to be that of the one that is overlapping in the top condition and therefore runs on an individual instance by instance basis... Or something...

    Thanks again!

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