- Home /
The question is answered, right answer was accepted
Why are tilemaps so bad ?
Everytime i use a tilemap I run into very weird problems.
The first time was when i used a box collider on a rigidbody. It would get stuck sometimes on the tilemap. I tried changing some details about the tilemap (I think it was adding a pixel on both x axis sides of the tiles but i'm not sure anymore) and of course I tried using a composite collider.And removing the multiplication with deltaTime didnt help either. I asked a couple of people whats wrong. No one could explain it to me.
I found out that if I use a capsule collider instead of a box collider on the object with the rigidbody this problem does not appear anymore. After like 80 hours working with a capsule collider I ran into another problem. This right here:
The rigidbody starts bouncing for no reason. My code is never telling the object to move on the y axis. Here are all the settings:
And here is the code which is moving the object:
I know that the problem comes from the tilemap because when i use an edge collider instead of the tilemap everything works fine but I cant rely upon any other collider. I have to use the tilemap for my next project. I thought about creating prefabs and using it like a tilemap or scripting my own tilemap myself but there's gotta be way to use this damn thing.
I would also be happy if anyone could give me an idea on how to do a workaround. The best idea i have is making a script which creates edge colliders based on the tilemap. Setting the rigidbody to kinematic when walking was another idea but i ran into a lot of other problems which are way harder to handle.
Answer by bl4ckfoot · Oct 16, 2021 at 04:19 PM
With the help of unity forum i managed to find out the problem. And of course the issue was on my part.
The problem is I misunderstood what a composite collider does. The composite collider merges the shapes of any Box Collider 2D or Polygon Collider 2D that you set it up to use. And logically you have to attach the composite collider to the object with the colliders. What I did wrong here is that I added the composite collider to the object interacting with the tilemap, because every source of information I could find stated that you have to do that. Also if you run into the same problem as me, don't forget to add a static rigidbody to the tilemap.
Here is the thread I opened up on unity forums. A guy called Zephus explained why that happens and how a composite colldier fixes the issue. Tilemap bug
Answer by vonchor · Oct 15, 2021 at 09:04 PM
don't know it this helps but there's a warning message on the tilemapcollider2d.
I knew about the warning. I ignored it because of i misunderstood what a composite collider does. Thank you for trying to help me anyway.
I found the solution. I will post it in another reply.