Hello Guest

Author Topic: Problem with tilemap chunk colliders  (Read 3930 times)

wertymk

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Problem with tilemap chunk colliders
« on: June 06, 2015, 03:57:59 pm »
I'm making a little platformer using physics to move my characters and other objects. I've run into a little problem with the tilemap chunks and their colliders. Sometimes if there is a border of two tilemap chunks on a flat surface my characters are walking along they will collide with the border when moving over it, seemingly hitting an invisible wall. It seems the collider of my character is just enough inside the tilemap collider he is standing on to hit the corner of the collider of the chunk he is trying to move on to.

I tinkered with the source code and found out that there is a hard coded limit of 32 for the size of the chunks, so I tried increasing it so that my level would be only one chunk. This works but poses another problem, the number of tris rendered goes up by a lot, from about 3k to around 19k, I guess because the entire level mesh is now being rendered all at once. It doesn't seem to cause much of a performance hit right now, even though I'm working on a pretty low-end laptop, but I'm afraid it might become a problem later on if my levels get bigger.

Is there a way to have the tilemap be composed of multiple smaller chunks but still have only one collider? Or is there some other solution to this?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with tilemap chunk colliders
« Reply #1 on: June 06, 2015, 11:26:07 pm »
I think the easiest way to work around this would be to have 2 separate tilemaps, and write a script to update the second tilemap to generate the polygon colliders without any partitions. The first one can be set to generate no physics, and the second doesn't generate graphics at all. This can be done without having to modify tk2d code as far as I can tell.

wertymk

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with tilemap chunk colliders
« Reply #2 on: June 07, 2015, 10:53:13 am »
Hmm I'm not quite sure how I would write a script to update the colliders from outside the source?

For now I removed the chunk size clamping and do the collider updating manually by making duplicates of the tilemap, tilemap data and editor data where I set the chunk size big enough to cover the enitre level and set it to only generate colliders. This isn't very optimal though as I need to redo the duplication process every time I change something in the level.
« Last Edit: June 07, 2015, 10:59:19 am by wertymk »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with tilemap chunk colliders
« Reply #3 on: June 07, 2015, 12:20:51 pm »
You don't have to specifically generate colliders, just mirror the contents of the tilemaps (tilemap.GetTile / SetTile), except one of them is set up in the layers panel to only generate graphics and the other only generates physics.