I have a gameobject which is NPC, the NPC has a 2d box collider and a rigidbody 2d and the tilemap has a tilemap collider 2d, I have set the tilemap collider to a trigger but when in play mode the NPC goes straight to the edge of the tilemap how do I get the NPC to ignore some colliders?
The whole tilemap is a trigger? Do you know what a trigger does and doesn’t do? A trigger won’t get a collision response and will provide trigger callbacks to say you overlapped it. If this is new then I would really recommend following some starter/primer tutorials.
This is where you need to supply an image because this sentence is quite vague i.e. what does “the edge of the tilemap” mean?
All 2D colliders work the same, it doesn’t matter what type they are as physics doesn’t actually know anything about colliders, it only cares about the shapes the colliders make. Anyway, you control what hits what by using layers in the Layer Collision Matrix. This is shown in all starter physics tutorials.
See “Layer Collision Matrix” here:
i have recorded the issue. i have removed the collider from the tilemap the only thing that makes a different is not having a rigidbody on the npc. Even with the tilemap disabled it still moves to the edge of the tilemap at run time, the npc doesn’t fall off the screen it just move to the edge of the tilemap in any direction as you can see in the video.
It’s either you doing that in script of if you’re suggesting that it’s the physics system doing it then maybe you should turn on the collider gizmos so you can see if it’s overlapping something which is pushing it out.
You can also go to the Project Settings > Physics 2D > Gizmos and turn on all colliders and also get them to be filled-in so you can see the areas they cover.
Thanks for replying, it fixed the issue I had a game object with a collider 2d that I am using as the bounds for the camera.