How do I make player in front and behind multiple obstacles

Get help using Construct 2

Post » Thu Jan 21, 2016 3:16 pm

I want to make simple isometric game.

When player is behind object (its.y<obstacle.y) it should be behind it:
Image
When player is in front of a object (its.y>obstacle.y) it should be in front of it:
Image

I've made simple code to achieve this:
Image
but this works only for one obstacle. When there's more obstacles it doesn't work.

It works like this (please open in new window):
https://dl.dropboxusercontent.com/u/17601731/forum/c2/behindandinfront/index.html

CAPX:
https://dl.dropboxusercontent.com/u/17601731/forum/c2/behindandinfront.capx

Any ideas why and how to fix this?
B
54
S
14
G
10
Posts: 287
Reputation: 7,642

Post » Thu Jan 21, 2016 7:42 pm

Change the "for each obstacle" to "for each obstacle ordered by obstacle.zindex ascending"
B
85
S
27
G
85
Posts: 5,068
Reputation: 57,870

Post » Fri Jan 22, 2016 8:35 am

Tried this:
Image
and this:
Image

Unfortunately this didn't fix the problem.
B
54
S
14
G
10
Posts: 287
Reputation: 7,642

Post » Fri Jan 22, 2016 9:23 am

why not only set the z-order when needed instead of going through all objects every tick?

"on collision" should probably work, but you could ofcourse use "is overlapping"
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 » Fri Jan 22, 2016 9:32 am

I've tried this also. Didn't work for obstacles that are close each other.

With this code:
Image
(I had to add additional object (playerOverlap) that is players bounding box)

I get this result:
Image
B
54
S
14
G
10
Posts: 287
Reputation: 7,642

Post » Fri Jan 22, 2016 9:50 am

you wouldn't need a for each there, it probably does more harm than good in this case..
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 » Fri Jan 22, 2016 10:58 am

@LittleStain - this makes no difference in this case. In both ways I'm not getting the result that I need.

Please don't get me wrong - I'm grateful for your answers. I had also many theoretical solutions but they didn't work in this case.
Could you open my CAPX and try to modify it so it works?

Again - I'm not lazy :) and I don't want you to make work for me but theoretical solutions (that I had many) failed in this scenario.
B
54
S
14
G
10
Posts: 287
Reputation: 7,642

Post » Fri Jan 22, 2016 11:04 am

I would like an answer too, I've tried the same way you does and I never found the solution. I used 2 sprite , one for the top and one for the bot but it's a lot of work with all sprite. I really would like an answear too to this topic :)
B
9
S
3
Posts: 53
Reputation: 997

Post » Fri Jan 22, 2016 11:32 am

@tecbug

Have a look if that is what you want:
Image

The pick all is needed that you have not the problem that if you between two tiles, left and right, to stuck under one and above the other.
But the problem with this is, is the next tile, up or down, to close to you, you will be above or under both tiles
Image
B
23
S
3
G
1
Posts: 412
Reputation: 2,062

Post » Fri Jan 22, 2016 11:51 am

This works for me:

Image
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


Return to How do I....?

Who is online

Users browsing this forum: mchulet, tarek2, theinfomaven and 6 guests