- Home /
Using RigidBody2D.Cast to detect all collisions with a Tilemap + Composite Collider
I have written a physics script for my 2D platformer game that uses RigidBody2D.Cast to detect collisions between the player and the floor/walls and then apply the relevant forces, velocity change and movement. Previously I have been using box colliders for walls and floor separately, however to improve my workflow I would like to use Tilemap Colliders.
The issue I have is that when the player collides with a corner of a room for instance, they will clip through. This is due to the wall and floor now being part of the same collider so the Cast only picking up a single collision with a single normal (either the floor or wall, not both), which is not enough information to calculate the adjusted forces etc. The same thing happens when using a polygon collider.
Short of separating the walls and floors into different tilemaps or returning to the box collider method, do you have any ides that might solve this problem?
Thanks
Alex
Ok, I still haven't been able to work out a solution. I'm going to stick with box colliders for now, but would really appreciate it if anyone has any ideas concerning this.