[TILED TILEMAP] Round tile edges and collision

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


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


Share this post

Link to post
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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.