Going in front and behind objects?

Get help using Construct 2

Post » Sun Mar 06, 2016 9:48 pm

Here's what I'm trying to do: I want to make it so that the player object is displayed in front of a certain object, when it's below it and behind the other object, when it's above it, in order to create a simple illusion of depth.
In Game Maker each instance of an object has a Depth variable, so there I could just set it to the Y position. In Construct, however, there's no such thing. There's the Z Elevation, but changing it also scales the sprite and I don't want that.
I tried various methods like checking if the player object is overlapping with some other object and if its Y is Greater or equal to the other object's, but it doesn't work. So how exactly do I do this in Construct?

Thanks!
B
4
S
1
Posts: 13
Reputation: 376

Post » Sun Mar 06, 2016 10:12 pm

You can move an object between the layers or change the Z position on the current layer (even against another object).

Check the Z Ordering section: https://www.scirra.com/manual/132/common-actions
ImageImageImage
B
27
S
16
G
80
Posts: 1,014
Reputation: 44,747

Post » Mon Mar 07, 2016 4:38 pm

You don't understand. The problem is not which actions to use. The problem is that Construct doesn't seem to differentiate which instance of the object the player is in front of or behind. Let's say we have two palm trees on the screen, with one being slightly below the other one. The player overlaps with the higher palm tree and is below it. However the player object is not being drawn in front of the tree, but behind it, probably because Construct checks the Y position of the other tree, which is below the player object and therefore in front of it. So the same settings are being applied to every other instance of the palm tree object. I'm trying to make it so that it doesn't do that.
B
4
S
1
Posts: 13
Reputation: 376

Post » Mon Mar 07, 2016 6:05 pm

Many people made isometric games with C2. With such games z-ordering manipulation is a must, and they succeed so I am sure that everything is possible.

You can do any action on an instance or on an object (all instances) it's just a matter how you grab your SOL.

But I agree - I don't understant what's exactly the problem you describing.
ImageImageImage
B
27
S
16
G
80
Posts: 1,014
Reputation: 44,747

Post » Mon Mar 07, 2016 6:22 pm

Hi Bio,

There are a lot of tutorials and different methods that address the problem you are describing. Here is one example that I like - https://www.scirra.com/tutorials/4981/s ... den-player
Mistakes were made.
B
52
S
26
G
109
Posts: 1,607
Reputation: 61,635

Post » Mon Mar 07, 2016 11:09 pm

Here's a solution you can try:
Image
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Wed Mar 09, 2016 7:56 pm

Sorry for replying late. I'm afraid to say these methods didn't really work :/

The tutorial example doesn't work, because I don't want the player to be displayed at all when passing behind objects.

The method by Destitute doesn't work, because the actions, once again apply for all instances of an objects and this creates glitches, when the player passes around multiple layers of objects. For example: if the player is slightly behind one object, but also slightly in front of another object, the player object will be displayed behind both objects.

Does anyone have any other solutions?

Thanks.
B
4
S
1
Posts: 13
Reputation: 376

Post » Wed Mar 09, 2016 8:58 pm

The simplest is to put all the objects you want to z sort in a family (player, trees, walls, enemies). Then use a a for each ordered condition.

for each family1 ordered by family1.y ascending
--- family1: move to front
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Wed Mar 09, 2016 9:02 pm

Just change the blend mode so that your source is completely blocked instead of atop for the silhouette.

https://www.scirra.com/manual/146/effects

I think the one you want is Destination Over, but I'm not 100% sure. Quick experimentation will help you find the correct effect.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,607
Reputation: 61,635

Post » Thu Mar 10, 2016 2:02 am

BioMechanical wrote:Sorry for replying late. I'm afraid to say these methods didn't really work :/

The tutorial example doesn't work, because I don't want the player to be displayed at all when passing behind objects.

The method by Destitute doesn't work, because the actions, once again apply for all instances of an objects and this creates glitches, when the player passes around multiple layers of objects. For example: if the player is slightly behind one object, but also slightly in front of another object, the player object will be displayed behind both objects.

Does anyone have any other solutions?

Thanks.

I forgot to note, but my method doesn't work for you because all objects need to be on one same layer with the screenshot I posted, including the player.
I used to have multiple layers (one for the player/enemies), objects above Link (such as the bridge overpasses inside of Hyrule Castle), below Link (switches) but I switched to one layer and started using family y ordering since in my opinion, having too many layers can cause unexpected (nature of bugs, half of the time, you don't expect them...) emergent problems later on and having most if not all objects on one layer makes them easier to debug, as long as the y ordering is initially done correctly.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests