- Home /
Question by
bjorn van dijk · May 20, 2014 at 06:31 PM ·
objectdestroy
how do i destroy a spawned object
first off all sorry for my english i'm dutch and can't speak english that well
also i'm new to unity
what i want is to have a box collider and when i step in it it spawns an gameobject.
i already have that but now i need another box collider that will destroy that same object.
this is my code
#pragma strict
var Blokkade : GameObject;
var spawnposition;
function spawn_blokkade ()
{
spawnposition = Vector3(0,0,-50);
var temp_spawn_blokkade = Instantiate(Blokkade, spawnposition, Quaternion.identity);
}
function OnTriggerExit(o:Collider){
spawn_blokkade();
}
function OnTriggerEnter(o:Collider){
}
Comment
Answer by cryingwolf85 · May 20, 2014 at 07:26 PM
Attach a script with this:
function OnTriggerEnter(other:Collider){
Destroy(other.gameObject);
}
On the object that is to destroy the game object.