Correct collision in tile-based game

0 favourites
  • 8 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • 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.



    Here is the .capx:

  • The TileMap works correctly. You should search for isometric, that is what you want

  • Thanks for your reply.

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

    I want a RPG Maker-like look.

    I don't think its isometric.

  • Use Z ording

  • Z order and layer don't solve the problem. The player will then just overlap the object when standing behind it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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:


    System -> Every 0.05 Seconds

    System -> For Each SpriteObject order by SpriteObject.Y ascending

    SpriteObject -> Is on-screen


    -> 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)