Walk behind an object (Layers and 2.5 D Games)

Get help using Construct 2

Post » Wed May 22, 2013 4:52 pm

This is much easier with layers create two more layers, set your black wall to layer 1, the blue to layer 2 and your done, then changing your player from layer 0 (farthest from camera) to layer 2 send to top (nearest) when needed will mean any other objects added in future can just be placed on the correct layer without needing constant overlap checks
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Wed May 22, 2013 5:05 pm

@Pixel perfick Correct me if I'm wrong, but I don't think that will work, and here is why:

if you have 4 layers

0 background
1 <Place Holder>
2 Black Wall
3 Blue (collision) (and player)

The player will always be in-front of the wall... I would need to move the player to layer 1 in order to make him go behind the wall... see what I mean?
B
6
Posts: 35
Reputation: 370

Post » Wed May 22, 2013 5:24 pm

There are multiple ways to do this. the easiest way is to either send the sprite to the bottom of the layer or sent the sprite to another layer. Sprite: compare y - if above collision object - sent to layer 1 or sent to bottom of layer. These actions are at the bottom of the sprite possibilities. Z order.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Wed May 22, 2013 5:34 pm

Yes you would have to move the player to layer 1, but I don't see why that is an issue...

If your sure it won't work, I'm sure I don't know exactly what it is your trying to do, moving between the layers is just the same as moving up and down the z order, unless there is parallax scrolling involved it should work...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Wed May 22, 2013 5:37 pm

If you want me to, I can make you an example capx, meanwhile:
maybe you're interested in this too

example

And the capx
distance-Scale
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Wed May 22, 2013 5:42 pm

something went wrong with the links hope this works now

Example

distance scale
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Wed May 22, 2013 5:43 pm

Best way to do it is to use families.

[code]+For Each (Ordered) FAMILY, Sort by Y Ascending
-> FAMILY : Move to top of layer[/code]
If you can't use families, then the Z-sorter plugin mentioned earlier would work fine, too.

Don't really recommend any other methods since the above two are the simplest ways to do it.

@Pixel perfick
Moving characters from Layer to Layer is not the same as changing the Z order. In each layer you have an X,Y, and Z coordinate. Z decides which object gets drawn on the top. Moving from Layer to Layer isn't practical for top down games because if you have a large number of characters/objects on screen, you'd need a layer for every one of them in order to properly display "depth", in every layout. Way more work than necessary, and likely a bad idea for performance as well (haven't tested layer limits myself). Layers are better used for parallaxing, HUDs, forest canopies, cloud shadows, weather, fog, environmental effects, backgrounds, collision layers, etc... rather than sprite sorting.

Besides, why make 100+ layers to accomplish what can be done in 1 event?TL222013-05-22 17:54:41
B
58
S
20
G
7
Posts: 305
Reputation: 8,804

Post » Wed May 22, 2013 6:13 pm

@TL22 I went and got the paid version... I created a family with the wall and with the player object... I'm not sure how to setup the event.. I found the foreach, but I can't find a sort anywhere... and do I want to run this every tick? or on player move? or?
B
6
Posts: 35
Reputation: 370

Post » Wed May 22, 2013 8:14 pm

Ah! I got it working!

View Demo
Download capx
B
6
Posts: 35
Reputation: 370

Post » Wed May 22, 2013 8:16 pm

(Note, the RED thing is the wall, with the hitbox in yellow. The blue this is the "player" with yellow being the hit box. Use the arrow keys to move.

I did On Player Moving, do the sort.
B
6
Posts: 35
Reputation: 370

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 26 guests