Hello Guest

Author Topic: Having an issue with TileMaps' Colliders on Unity 4.3  (Read 12333 times)

mithosx

  • Newbie
  • *
  • Posts: 3
    • View Profile
Having an issue with TileMaps' Colliders on Unity 4.3
« on: December 15, 2013, 04:09:57 pm »
I'm having an issue with setting up colliders for TileMaps created with 2d Toolkit with the latest version of Unity.

I set the TileMap to use the new Physics 2D engine when I created it and used Box Trimmed for the tiles in Collider Type settings.

The issue comes when I try to walk into a wall and usually only happens what the character is walking towards the wall from left to right, the collider is not detected and the character walks right into the wall and gets stuck in it, even though I can see the collider and control its size fine when I select the TileMap Render Data.


I noticed that the problem is fixed if I modified the size of the collider manually after committing the TileMap. However, editing the TileMap again will result in the issue happening again.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #1 on: December 15, 2013, 07:43:36 pm »
How are you moving your sprite?

mithosx

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #2 on: December 17, 2013, 04:32:22 pm »
Quote
How are you moving your sprite?
Unity native 2D physics by changing Velocity.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #3 on: December 17, 2013, 09:52:40 pm »
I'm at a loss - can you please email a repro case to support at unikronsoftware.com? I'd like to get to the bottom of this.

mithosx

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #4 on: December 29, 2013, 05:48:08 pm »
It seems that my problem was from the box colliders I've added around the character. I played around with their sizes and now it's working fine. Sorry for the confusion, still learning these stuff. Thanks for trying to help.

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #5 on: February 24, 2014, 11:45:39 am »
I'm experiencing something like that. I create a tilemap consisting of a hollow box drawn with a square tile of 64x64 (with a trimmed box collider). Then I put a ridigbody2d box inside it and make it move with gravity. The player can rotate the camera (and the gravity vector is rotated at the same time), so the rigidbody2d can be constantly rolling inside the box and hitting the tilemap walls randomly. Then I find that the rigidbody2d goes inside some of the tilemap walls and then gets stuck into them. It always happens with the same walls.
 To fix the problem, I have to change the trimmed box collider of the sprite of the tile that makes the wall for a polygon collider (essentially the same collider but drawn by me). Then all collisions work fine. Could there be a bug hidden in the construction of a tilemap collider?
 I'm using the latest Unity with the latest TK2D (even tried with the last beta).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #6 on: February 24, 2014, 12:02:56 pm »
What walls specifically? Any pics (scene view with the mesh selected so I can see the collider please). The colliders stop at partition edges, continuous edge colliders otherwise.

Your object could also be moving too fast, and could also be a combination of this & above.

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #7 on: February 25, 2014, 04:57:49 pm »
I will try to prepare the simplest test case for you to try. It's not easy as I have already tried but the test scene from scratch works fine. I'll try to revert the original scene that had the problem (remove the polygon colliders and re-set them as trimmed boxes) and take it out of the entire game.

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #8 on: March 13, 2014, 05:03:02 pm »
I have just sent an email to the support address with further information.

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #9 on: March 18, 2014, 02:47:30 pm »
Ok, after some emails with Unikron, the solution I have come across is to only use circle colliders when colliding with the tilemap edges. Circle colliders seem to be the only reliable ones when colliding with edge2D. So I have disabled the polygon collider and "filled" the colliding object with circles until conforming the desired shape. It is not perfect, it is indeed annoying, but works fine. It makes me think of the Lumpy Space Princess in Adventure Time, but it kind of works... hehehe
It is faster than disabling TK2D tilemap edge optimizations, which I tried and worked ok, but it was not a great idea performance wise.
Just wanted to let this idea for the people that "hit the same wall"  ;)

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #10 on: March 18, 2014, 03:45:52 pm »
I haven't noticed any issues with collision and am using rigidbody2ds and edge colliders. What scale are you using? 1 unit = 1 pixel?

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #11 on: March 18, 2014, 04:18:37 pm »
Hi! Well, my rigidbody2d's collide fine as long as they have circle colliders. If they have box/polygon colliders, then they seem to be fine until in some tilemap sections they can suddenly go through the edge and pass to the other side of the edge. But it only happens in some (unknown to me) circumstances. It is not as common as it could seem reading the post.

It is true that if I disable tk2d edge optimizations, with more vertices over the edges, everything goes fine again. So it made me think of scales and so, but I had no luck tweaking things.
I have set "20 pixels per meter" in TK2D. The leading object in my game, a ball, has a collider radius of 1.46f. The objects that show the issue (the biggest ones: some brick-like boxes) are 3.2f x 6.0f. Do you mean they could be scaled too big for Box2D?

Thank you in advance!

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #12 on: March 18, 2014, 05:11:04 pm »
Not really sure, was just speculating if you were doing 1:1 scale the numbers would be massive. I've never had a problem with the 3D physics and a large scale, but for the Physics2D I brought it way down to 1:64 and everything collides perfectly (box colliders with edge colliders - not using circles). Precision wouldn't be an issue at your scale, though.

ccampama

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Having an issue with TileMaps' Colliders on Unity 4.3
« Reply #13 on: March 18, 2014, 08:55:32 pm »
Yeah, I also did never experience such a problem with PhysX, but that's my first experience with Box2D and I also guess it could be an issue related to scales. But I made some rough tests with no luck  ???