1
\$\begingroup\$

I have created the below tilemap in tiled and I am wondering about a good approach to "separate" these two different heights in the map. I would like to keep it tile based, so adding a object layer for collision detection is a no for me.

enter image description here

I would like the player to move from the low ground to high ground using the ladder. But as you can see, two walkable tiled adjacent to each other should not be "connected" since they are on different heights.

Since I can only add properties to the tile in the sheet and not on the map itself afaik, I cannot mark the heights on my map. So I guess I have to work with different layers for each height. Check if the layer the player currently on has a tile or something, if that is even possible.

The reason I do not want to use a object layer is simple. My creatures move from tile to tile and I just want to check if that tile is walkable and on the same height level. No need to test vs a rectangle or polygonal object.

What I am actually looking for is having properties per coordinate. This would make it a lot easier (pseudo code):

tileMap[x][y].floorCount;
tileMap[x][y].walkable;

instead of:

map.getLayer(player.currentLayer).layerMap[x][y].tileExists;
map.getLayer(player.currentLayer).layerMap[x][y].walkable;

I simply cannot add properties to a "global" tile (tiled seems to only allow me to add properties to the tile on the sheet which is carried over to every usage of it. This image uses that same corner tile as in the above image, only this time the player is allowed to cross it, or perhaps hop over it.

enter image description here

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Why dont you add a passagability into the four directions to the tiles? For example the edge-tiles disallow a movement to the right and from the other side? \$\endgroup\$
    – Raildex
    Commented Apr 9, 2016 at 10:13
  • \$\begingroup\$ @Raildex How would I do that in tiled? I cannot set properties on cell level. I can set properties on the specific tile in the sheet but that carries over to each time I put that tile in a cell. That is the actual problem, if I could add properties on x/y then this would be an easy fix and setting floor level would actually be better then edge connections. \$\endgroup\$
    – Madmenyo
    Commented Apr 9, 2016 at 10:35
  • \$\begingroup\$ I think newest versions of Tiled support this level of fine-grained collision detection. There is a collision properties box somewhere in the options that lets you do that, choosing what sides of a tile are passable. Another option is to make a copy of that tile on your map and then setting the property only on that copy \$\endgroup\$
    – rlam12
    Commented Apr 9, 2016 at 17:40

3 Answers 3

3
\$\begingroup\$

In Tiled you can add layers. Use a layer for the ground level, elevation1, elevation2 etc.

Define a ladder/stairs tile with a property (in the tileset tile property) to indicate the player can move up or down one layer.

\$\endgroup\$
6
  • \$\begingroup\$ This is what I have currently. But how do you suggest checking collision? Each move I have to check if the current layer the player is on has a tile? It feels like a hacky work around. \$\endgroup\$
    – Madmenyo
    Commented Apr 9, 2016 at 13:34
  • \$\begingroup\$ Why would that be 'hacky'? It is exactly what tilemaps do. Every frame Link is checked against the Hyrule tilemap, every frame Sonic is checked against the ledges on the Green Hill Zone tilemap. How else would the character know if it is still on a walkable tile while moving? \$\endgroup\$
    – Felsir
    Commented Apr 9, 2016 at 13:53
  • \$\begingroup\$ if (tilemap[x][y].iswalkable) instead of if (map.getLayer(player.getCurrentLayer).getTile(x,y).exists && map.getLayer(player.getCurrentLayer).getTile(x,y).isWalkable) \$\endgroup\$
    – Madmenyo
    Commented Apr 9, 2016 at 14:13
  • \$\begingroup\$ I find it much more convenient to store that "floor" variable in the actual x,y location then to have it on a separate layer. It is also error prone, when layers are overlapping. \$\endgroup\$
    – Madmenyo
    Commented Apr 9, 2016 at 14:16
  • \$\begingroup\$ And that is hacky because..? In the game logic, a map has layers, layers have tiles. One could make the Walkable property include the 'exists' (non existent tiles are defacto unwalkable). \$\endgroup\$
    – Felsir
    Commented Apr 9, 2016 at 14:17
3
\$\begingroup\$

Instead of defining a tile-type as "blocked" or "walkable" in general, define the four edges of a tile as "blocked" or "walkable" separately (a completely impassable tile would have all edges as "blocked"). That way you can define a tile-type like that upper cliff corner which can be entered and left through the west-edge and north-edge but not through the east-edge and south-edge.

This system also allows you to create "thin" obstacles like fences which don't block a whole tile but only the edge between two tiles.

\$\endgroup\$
1
  • \$\begingroup\$ Yes, I want this on a cell level but I can only assign this on the actual tiles and these settings are used each time I am using a tile. It would work but if I ever want to use that same tile with different "block" settings I cannot, since they would carry over to all other usages of this tile. \$\endgroup\$
    – Madmenyo
    Commented Apr 9, 2016 at 14:19
0
\$\begingroup\$

Looking at your responses to the two answer here so far, I don't think you're going to find a solution that works the way you want it to without it being some level of hacky because you're not using objects. The actual picture tiles do not have any properties support in Tiled. The only thing that has support for properties are the layers and objects.

The only solution I can think of that might work is to keep track of specific tile IDs (the picture tiles, not their location) and use that to help you determine things. For example, if your player steps on the "right-cliff edge tile", they can not move right anymore. If the player steps on to a "ladder tile", then they are allowed to move onto a cliff-edge tile.

I honestly wouldn't suggest this though as its VERY hacky. I think honestly using layers or objects is going to be a much better solution for you in the longer run and will allow you a lot more flexibility down the road, even if it doesn't seem as "nice to write in code" right now. That's what helper functions are for. :)

\$\endgroup\$
1
  • \$\begingroup\$ In Tiled you can give properties to individual tiles, and this is exactly what it is for. It's not hacky that way because it's abstracted into the map itself. \$\endgroup\$
    – Oliver
    Commented Nov 7, 2016 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .