How can I disable my projectile from colliding with other IsTrigger enabled colliders?
My project is currently setup as this:
I have a projectile with a Collider2D with IsTrigger enabled (for detecting when I hit something).
Then I have a Player with two Collider2D:
A “normal” collider with IsTrigger disabled: For checking for movement, getting shot, etc
Another collider that has IsTrigger enabled: For checking for objects the player can interact with
Problem:
When I fire a enemy projectile toward the Player it collides with the Player IsTrigger enabled collider and never reaches the “normal” collider.
Projectile has a script containing OnTriggerEnter2D function that detects collision.
Hello!
if this is the first time you use physics layers then it will be a bit difficult to understand
basically you have to separate the two colliders of the player into two gameobjects. the trigger collider must be a child of the main player gameobject.
then create three new layers:
Player (for the player gameobject)
PlayerInteraction (for the player child gameobject, this controls the player interaction with objects)
Bullet (for the bullet gameobject)
Then set the collision matrix to avoid the bullet to collide with the player interacion layer.