- Home /
Have projectile destroy some objects on collision but normally interact with others according to its properties.
I'm making a simple 2d game and I'm shooting a projectile (arrow) that has a collider on it and it's hitting boxes that also have a colliders on them.
Depending on whether the arrow is on fire or not i want to
Normal Arrow : Bump on boxes, interact like normal physics object.
Fire Arrow : Destroy boxes and go through them - maintain current arrow speed, ignore collision altogether.
It seems that for the boxes selecting IsTrigger (and using OnTriggerEnter2d) solves half of my problem and not selecting it (and using OnCollisionEnter2d) solves the other half of my problem.
What would be the best way to approach something like this? (which surely has been done before in other games)
Answer by MT369MT · Jul 01, 2018 at 08:52 AM
Hi, you could use a trigger on your fire arrow instead on your box. Box and normal arrows have colliders without trigger and fire arrows with trigger. When the fire arrow detect the box with OnTriggerEnter it destroy the box.
Thanks. Your solution is correct though a bit counter-intuitive (arrows having different types of Collider).
However, that way i'm losing collision between fire arrows themselves but that's not too much of a problem i suppose.
Your answer
Follow this Question
Related Questions
Trying to make object turn red OnTriggerEnter 0 Answers
OnCollisionEnter being called without the colliders actually colliding 1 Answer
Strange issue with collider 1 Answer
Collision detection when no collision happens,OnCollision is called without a collision 1 Answer
What else is to be done if players falls through the floor? 0 Answers