- Home /
How can I prevent my player from passing through tiles?
Hello. I am making Pokemon style game using the tile system in Unity. I am having a problem restricting what tiles my player can, and cannot walk on (or pass through). I have my appropriate tilemap that I want my player to NOT be able to walk in (in this case it's some rocks), and I have added the tilemap collider 2d, and composite collider 2d to this tile map. Yet my player still can pass through these tiles. What am I doing wrong?
Hi, Be sure they are not set to trigger and check if also your player has a Collider2D (NOT trigger) and a Rigidbody2D.
Also in case you fiddled around with physics settings: make sure that the physics layer collision matrix enables collisions between the layers of your environment and your player.
I have added all of these things. Yet it still doesn't seem to work.. here are some pics:
Basically I'm trying to prevent my player from being able to work over the sign (test01 tilemap).
Answer by MT369MT · Jun 07, 2018 at 04:52 PM
You have the BoxCollider2D unchecked in the inspector. turn it on and it should work.
Thanks! That worked! But it seems now I have a problem with my player getting stuck on these tiles that collision, if you walk into them. It also seems to move my character in an unintended way if you move past them as well. Any suggestions?
I've tried adding a material with 0 friction, but it doesn't seem to work.