- Home /
destroy a non-trigger object hitting a trigger object?
so i got this game, and the enemies got the is trigger checked so the bullet will go past them and destroy more enemies.
my game changes the bullet types though. and 1 bullet should get destroyed while hitting the is trigger enemy.
so that being said, how can i destroy an game object when it hits a "is trigger" game object?
i know how to destroy an "is trigger" objects when it got hits by a non-trigger object.
but how to do it in reverse?
Im not sure I am following you...OnTriggerEnter passes a collider as a parameter and OnCollisionEnter passes a Collision parameter which has a collider as a member. In both functions you can access the gameobject that is hitting you.
true. sorry but im a newbie. lets take it this way.
i got a cube that got its is trigger on.
then i throw a sphere at it that has its trigger off (just a normal collider)
the cube has a script
function OnTriggerEnter(collisionInfo:Collider){ if(collisionInfo.gameObject.tag=="bullet"){
Destroy(gameObject,0.001); }
so when the bullet hits. the cube gets destroyed right?
i was wondering how to destroy the bullet this time.
Answer by PAEvenson · Jan 10, 2013 at 02:50 PM
Oh thats easy:
Destroy(collisionInfo.gameObject,0.001);
im sorry im really new at this where should i attach that?
on the cube that has ontriggerenter?
if youre destroying both the cube and the sphere put it directly user the Destroy(gameObject,0.001); inside the cube script
Your answer
Follow this Question
Related Questions
Have bullets be destroyed when they collide with ANY collider 0 Answers
Destroy a specific object on trigger? 1 Answer
Sword Kills Enemies From Far Away 3 Answers
Distance destroy object 3 Answers