- Home /
How do I have an object ignore collisions with one collider in an object but not a second one
I'm currently making a 2D game where I want the hit box for the player to be smaller than the sprite itself but still have the player fit into the camera view without clipping through the edges. to do this, I have a normal collider on the outside of the sprite and an isTrigger collider on the inside. is there a way for the incoming obstacles for the player to dodge to ignore the collision with the first box and not the second? would it be better to use an empty object, parent it to the player (or vice versa) , and give it it's own box to trigger the player being hit?
I would like to add that it is indeed easier to do it with an empty object that's parented to the player. I would still like to know if the former approach is possible though
Answer by unity_ek98vnTRplGj8Q · Apr 21, 2020 at 03:08 PM
Yes, you can use Physics.IgnoreCollision to tell colliders to ignore collisons between eachother. You would have to call this between your character collider and every projectile/obstacle that you want to avoid, however, so yes I recommend putting your colliders on different gameobjects/layers which is a much easier solution.
Your answer

Follow this Question
Related Questions
gameobject.findwithtag not working to all objects 1 Answer
Can't get Physics2D.IgnoreCollision to work on multiple objects 0 Answers
Two colliders in one Game Object, one is trigger. How to change size of both? 1 Answer
Why is my OnTriggerEnter2D(Collision2D other) function not working ?... 3 Answers
Make object stay on the Terrain, while the isTrigger is checked 0 Answers