Z Order - walking in front of & behind a wall

For questions about using Classic.

Post » Sun Jan 18, 2009 7:51 am

Hello everybody

I'm new to this. I've done the Ghost Shooter tute and Platform school 1, 2 and 3, but not 4 & 5. They need 0.98.5. I have 0.98.3 and don't feel like mucking around with it yet. I don't know how to upload a cap file to these forums so have made a screenshot.

I have made a demo of a person walking behind a wall. When they walk around it they collide with a hidden object that changes the z order of the wall. They then walk in front of the wall.
When the person goes back again, they pass that trigger object and bump into another one that changes the z order back again which has the person behind the wall.

It works but seems clunky to me. Is there a more elegant way of achieving having a person being able to walk behind and then in front of a wall?

B
4
G
3
Posts: 41
Reputation: 982

Post » Sun Jan 18, 2009 8:06 am

might be able to trigger the z-order with the Y value of the player, relative to the wall.

if Player.Y > wall.Y
--put wall behind player
else
--put wall infront of player

or something

edit: if you use families for the code, you may need to have the Wall be first in the condition, so that it knows which wall to use. play around with it.
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Sun Jan 18, 2009 6:08 pm

Yeah, use the Y co-ordinate. You really ought to upgrade to 0.98.5 too, there are some important bug fixes.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Sun Jan 18, 2009 6:38 pm

I suggest:

put all objects to be sorted in a family
Add event:
For each object (ordered): family.y
- send family to front (or back, I can't remember at the moment)

Then it's all sorted automatically.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Jan 18, 2009 8:55 pm

Thanks everybody

I like the Y ordering idea. I will try it out. Downloading 0.98.5: done. I had already tried putting the walls in a family. But the rear wall needs to back in the z order and the near wall needs to be at the front if the person walks between them. So I can't treat them the same. However I will try dfyb's advice of putting the wall first in the condition.

Thank you
B
4
G
3
Posts: 41
Reputation: 982

Post » Mon Jan 19, 2009 6:03 am

Try using family.bottom instead of family.y. Does that work?
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Tue Jan 20, 2009 4:54 am

Arima
Is this what you mean?



I'm just winging it with families. I don't really know what I'm doing. The family is called Blue. When I run the demo, it seems to reference the bottom point of the bottom member of the family. That is, the near wall. When I walk up to what should be in front of the rear wall nothing changes. I am behind the near wall and behind the rear wall too.

Just in case anyone is in the mood to waste a few minutes, here's the link to my cap file.
[url:284rgjdb]http://www.steekr.com/n/50-17/share/LNK825149755704efce7/[/url:284rgjdb]

Once the cursor is hovered over the file 'zOrderYpositions' a green arrow comes up in the top right hand corner. Left click on that and the option to download comes up.
B
4
G
3
Posts: 41
Reputation: 982

Post » Tue Jan 20, 2009 3:35 pm

Nope. This only requires one event.

First of all, put every object you want sorted into the blue family, the man, player, walls, all of them. You might want to make a family specific for this - I made a family 'sort'.

Second, make a new event, and double click system. Then select "for each (ordered)'. Then select the family blue from the object picker, and enter blue.bottom in the order expression text field. Leave it on ascending.

Next up, click new action, and send blue to front.

So it should read:

For each Blue ordered by blue.bottom Ascending
- Blue: send to front

That's all there is to it!
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Wed Jan 21, 2009 4:53 am

:D :D :D :D :D :D :D
Arima, you're a star. That worked perfectly. Thank you so much. My understanding of it is that the bottom of all objects in that family are automatically compared to each other to sort out the z order. That's a piece of art! Thank you.
B
4
G
3
Posts: 41
Reputation: 982

Post » Wed Jan 21, 2009 6:15 am

Welcome, happy to help :)
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests