Correct collision in tile-based game

Get help using Construct 2

Post » Wed May 07, 2014 7:39 pm

Hello,

I was playing around with the tilemap object and encountered a problem with the collision. I put the objects on a new tilemap and made it solid. The character can walk behind the objects just fine, but if he stands in front of them, the objects actually cover the player instead of the player covering the objects.

Correct: Image

Problem: Image

Here is the .capx:

https://dl.dropboxusercontent.com/u/96203257/Construct%202/test.capx
B
8
S
2
Posts: 110
Reputation: 1,463

Post » Wed May 07, 2014 8:51 pm

The TileMap works correctly. You should search for isometric, that is what you want ;)
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Thu May 08, 2014 8:31 am

Thanks for your reply.

I am not sure if isometric graphics are what I am looking for.

I want a RPG Maker-like look.

Image

I don't think its isometric.
B
8
S
2
Posts: 110
Reputation: 1,463

Post » Thu May 08, 2014 10:02 am

Use Z ording :)
B
14
S
6
G
3
Posts: 83
Reputation: 4,228

Post » Thu May 08, 2014 10:15 am

Z order and layer don't solve the problem. The player will then just overlap the object when standing behind it.
B
8
S
2
Posts: 110
Reputation: 1,463

Post » Thu May 08, 2014 10:28 am

z order does make a difference. You need to update the z-order during playtime. If your character is below the obstacle, render the player above. If your Character is above the obstacle, render it below of it.
B
44
S
10
G
8
Posts: 437
Reputation: 6,463

Post » Thu May 08, 2014 10:31 am

And how to do this with all the objects? The tilemap with the objects is on a separate layer but is still part of one big tileset. How to change the z order of just the objects? Seems like it would decrease the performance extremely. For each object the z order needs to be different, since the points are different for small objects and big objects like houses or trees.
B
8
S
2
Posts: 110
Reputation: 1,463

Post » Wed Jun 04, 2014 12:29 am

I wanted to bring up this topic again, as I've been looking for a solution myself.

Ordering sprite objects is pretty easy to do in a non-costly way. It could look something like this:
CONDITIONS:
System -> Every 0.05 Seconds
System -> For Each SpriteObject order by SpriteObject.Y ascending
SpriteObject -> Is on-screen
ACTIONS:
-> SpriteObject -> Move to top of layer

However, Tilemaps seem to be another story.

Someone please correct me if I'm wrong, but I don't think there's a simple, effective way to have a Sprite to pass behind or in front of a tile in a tilemap based on Y position, since there is no way of changing the Z-order of individual tiles. You could change the Z-order of the entire tilemap based on a sprite's position, but that's not really ideal at all for a bunch of reasons.

The only workarounds I can think of would be:
- Use sprites more often. This would be the only way to effectively have a small cactus like in the first post.
- Have two tilemaps, one for tiles that the sprites will always pass in front of, and one for tiles that sprites will always pass behind. This would be effective for something like the large trees from the third post, where you could have a base that the player always passes in front of, and upper parts of the tree that the player always passes behind. Though in this case, it would probably be more efficient to use a sprite for the tree instead.

If anyone has any other solutions to add, I'd love to hear them.
(M.A.D. are my initials. I'm not the least bit angry, really!)
@madguy90
B
11
S
4
Posts: 41
Reputation: 1,671


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests