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

Just started using Construct 2? Post your questions here

Post » Wed Dec 23, 2015 1:10 pm

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
B
3
Posts: 2
Reputation: 179

Post » Wed Dec 23, 2015 10:29 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 24, 2015 12:01 am

LittleStain wrote: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!
B
3
Posts: 2
Reputation: 179


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest