Jump to content

[TILED TILEMAP] Round tile edges and collision


rybaqs
 Share

Recommended Posts

So, i've got topdown game i'm working on, and I use tiled to make JSON tilemap which then I load in phaser 3. Everything works great, I've got collision (which I set between range of tiles), but here's the problem: some of tiles have round edges or are should be only partially blocking player from moving, yet in phaser I set collision on whole tile (which has one number).

Is there a way (and as I recall from past there should be, couse I already toyed with phaser 2 some years ago) to set collision per tile?

Here's what I would love to fix (character standing on water, couse tile he's on has no collsion, couse it's partially a DIRT, and partially a WATER):

1.png.6a0a3aaf14702dc105faee2397dd6a7a.png

And maybe I could somehow use this information (that as I presume is already in JSON file, made by TILED):

2.png.885e1c2acc441217948708212a3c8d59.png

Link to comment
Share on other sites

You could set a callback for the tiles, make a collision test of your own in the callback function. If all sides of the tile should be collidable, return true immediately, otherwise check where the tile is overlapped and return true only if it's where it's solid (maybe just check for collisions, and if it reach the end of the function return false). I never used Tiled in that way but you should be able to navigate through the tilemap object (or cache) to find the information you refer to and implement that in your callback.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...