Tilemap Collider 2D w/ Composite Collider Not Working

Hi there,

I’ve implemented a tilemap into my 2D scene using the Unity Tilemap asset. When I setup the tilemap to use a “Tilemap Collider 2D” (equivalent of a box collider per tile) the A* grid seems to work great.

However, if I set the tilemap to use a composite collider (changing the box collider per tile setting to 1 collider per shape (not tile)), the A* grid is unable to show the walk and no walk areas (only walk areas show).

It would be nice to be able to utilize composite colliders as it reduces the number of collision areas on the screen, thus making it a bit lighter on cpu utilization.

Hi

This seems to be a Unity bug I think. My package uses the Unity physics methods Physics.OverlapPoint and other similar methods that claim to return if there is an obstacle at the specified position.
I did find another user with the same bug: https://www.reddit.com/r/Unity2D/comments/7qoqnv/composite_collider_2d_bug/?st=jejqdh9m&sh=b0b14931

Any update to composite collider?

I do not know if that bug has been fixed. You could try out the latest Unity beta perhaps?

Fixed in today’s 4.2f2 LTS update. Though I didn’t find that been mentioned in changelogs.

1 Like

Hi Aron any news on this I need my titlemap with compsite collider working

@Thai_Binh_Nguyen according to @favoyang it has already been fixed. Are you using a somewhat recent version of Unity?

I’m on 2017.4.6f1 which one higher version of favoyang mention above. Can you check it again?

I’m using 2018 2.0b11 now and it works in this version.

1 Like

thanks @favoyang this one 2018 2.0b11 still beta right?
When it release I will try it, thank you a lot

@favoyang @aron_granberg
I tested it today it not working. @favoyang can u give some guide or screenshot?
@aron_granberg please check it out
I use latest unity version 2018.x

I know this is an old post, but I was also trying this today and realized the issue I was having. By default, the composite collider uses “Outlines” for its “Geometry Type” attribute. If you change this to “Polygons”, it may work for you. This seems to fix the issue if the graph wasn’t working properly if the node collider was able to fit entirely within an obstacle.

1 Like

My tilemap inspector

My player inspector
player

I think my setup is very trivial

  • The tilemap (walls) is a static body, collider geometry type is outlines.
  • The player is driven by pathfinding module, which reply on the tilemap collider to find the obstacles.
  • The player is also a kinematic body with trigger collider to detect enemy or door.

Anyone with problem on composite collider may create a small project on github to help reproduce the issue.

1 Like

Did you manage to solve this? I have a similar setup in my project, and my collisions aren’t being recognised

Hi

I think the issue is that CompositeCollider2D -> Geometry Type = Outlines has to be changed to Polygons. The reason is that if only outlines are generated then the physics engine cannot distinguish between inside and outside the collider. So things like Physics2D.OverlapPoint will return true even inside the collider.

1 Like

I was having this problem and this fixed it!

1 Like

I can’t seem to get this working either. I feel I’ve setup exactly like you said. Not sure if it matters but I have multiple tilemap layers. Two have obstacles. I’ve testing with one atm. All areas are walkable. It’s recognizing the colliders. Version 2019.4.6f1

Ok got it working. I forgot to check the use 2D physics and I had to set the TileMap with the obstacle on it’s own layer from the others.
image

2 Likes