How to manipulate objects in Z order ? Which is on top?

0 favourites
From the Asset Store
Several elements of the game interface hidden objects
  • Hi!

    Is there any way to check (making condition) which object is on the top in z order, and which at bottom?

    Im making a prototype of game, where the order is the main feature, and its important to solve pieces in right order (Z order) so how to make condition, that will check, which object is over another object (in front of) ?

  • Perhaps use layers ?

    And use the layer reference numbers.

  • You can find object z-position using condition in the event system. Select the object you want to check and scroll all the way down under the z-order conditions, there is one called pick bottom/top.

  • Okej. But how can i make condition like:

    When object A is over Object B, and Object B is over Object C - Go to next layout (complete level or something like that). How can i check / detect the order of objects, to complete level or not?

    Ordering by the layers? Hm.. so, when i want to make that order: Object A = 1 (on the bottom), Object B=2 (over object A) and Object C=3 (its on the top, covering A and B). And the actions are: when im click on the object A -> Object A move to the top (I can change that to: move to layer X [by the way, there is no action like 'go to next/upper layer] but than, all the objects will go to the top layer, so how to detect the order then?

    In the layout, there is an order, to sort objects in Z (i know its a fake Z, because of 2D) so the system knows, about the order.. So it should be a way, to controlling that in event sheet veryfing etc..

  • Why do you need to check the Z order in order to which to another layout? You can just place invisible object or teleport it to player location when lvl is suppose to end, and use on collision condition to progress to next lvl.

  • Because i have an idea for my game, where the objects overlaps on themselves like in origami, and the Z order is the main feature its puzzle game.. so the veryfing Z order is the only way to decide if level is complete and you can go to next or not.

  • I see. Well you can place each object on different layer, and check the layer number, so if the wining object is at layer one then go to next level(or something similar to that, I do not know how you planed your vents).

    Or you can use the pick top/bottom condition to check if the object is on top of z layer, and if is trigger the wining condition.

  • Put all the objects that need z in a family.

    Then give this family a family instance variable called z. Then each object in that family will have an instance variable z. You can then use that z for everything like setting z of object or getting z of object etc. Basically you are giving the object a 3Rd dimension.

    I am doing exactly this here for the rings and space invader sprites ... every tick I am sorting the objects according to their z instance variable by using for each ascending by instance variable z.

    https://drive.google.com/open?id=0B6AQ9 ... WNIMmlpMEE

  • With layers manipulating - it will not work as i want.. because the game is based on changing the Z order in the objects by clicking on them or moving. When I move the object A in direction to object B, and it overlap / cover object B, than I can move object A back, and than move object B on the object A, so then object B will overlap / cover (will be i front of object A).

    I tried that condition with 'pick top/bottom' like: object A - pick TOP instance > go to next layout. There is no option/condition like " If object A is on the "top" , or in front of object X > go to next layout ... or maybe you know the way to do that?

  • NetOne, family with Z instance is interesting idea, but how can I check which object is upper, and which is below in that Z order? For example. I have 3 objects; triangle, square and circle. At the start of the layout, the circle is behind square, and square is behind triangle. So the triangle is on the top, square is below the triangle and circle is on the bottom at z order. Now, i can changing their position in Z order by clicking on them (for example with condition like; when click on object > object move on the top). And that works fine - I can manipulating, which object is upper, and which is below..

    But to complete level, i have to set objects in that order: Circle on the top, triangle is below the circle and the square is on the bottom of them. How to check that order in conditions, to make the level complete?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is an action for objects to move them to a desired layer.

    From what I read .. you need that.

    You can use compare 2 vars from system to check different objects their layer.

  • Give the family another instance variable Type. Give each type, triangle square etc a specific number for type. 1 for triangle 2 for square etc.

    For each level you need to define a win condition.

    Eg if object with iv type 1 has iv z 2 and object iv type 2 has iv z 1 then win.

    I would do this with an array. Eg define each win condition for each level in an array. Use 3d array use array z for each level. Xy for the win conditions.

    Note layers way might also work in place of z instance variable but you will still have to define your win conditions in an array tho, assuming you will have a few levels. I can't think of another way unless you want tons of variables flying around.

    The issue using layers is that you will have to have as many layers as the max number of objects. if small number maybe less than 10 then OK. But If u use z iv then u can have as many objects as u like and keep adding without worry to make very big puzzle for pro skillz gamers....

    Actually to avoid arrays, which can be confusing for inexperienced, then you could probably add another instance variable to the family for winz and if all winz = z then win....

  • NetOne, could you make simple example with that array 3D? It's possible in C2?

    I was afraid, that this will be impossible to make in C2 and learning C#.

    But if there is no way to check that, i will make the prototype without checking right Z order.

    You;re right.. in C2 i had to do that with a tons of variables and condition to each objects in each levels.. So 10- 15 levels is maybe possible, but 70 ? ..

  • Yes you can easily do this with C2. But sorry man , the only reason I can post on this forum is that I am at work and just keep the forum open while I do my real job work tasks.

    I can’t do any actual C2/C3 work at work.

    Once I leave work it is all kids and wife stuff.

    I can only use C2 on the weekends late at night.

    Maybe someone else will pitch in with an example

    but actually I don’t recommend looking at other projects if you want to seriously be a game dev and learn and be autonomous.

    The way I would work is to try different things and divide my learning into small mini projects eg,

    Learn to use family with IVs

    Learn to use z sorting with IVs or layers.

    Learn to use arrays / dictionaries

    Learn to compare variables and set win conditions.

    after a while with C2 (and same with unity and programing)

    you will realise that there is 10 different ways to achieve the same thing.

    and if you know the 10 different ways then you can decide yourself the best way for your unique game without listening to ideas from people who don’t really understand your vision.

  • Ok, no problem I will learn about arrays 3d, read about that and try to do that by myself.

    I just thought, there is simply way to do that using conditions like "Triangle is in front of/behind Square" but its not..

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