This question was
closed Mar 19, 2018 at 05:30 PM by
Nosmo for the following reason:
solution found independantly
How can I destroy a prefab clone?
Im trying to destroy a prefab clone but all attempts have failed
This is what ive done so far:
//public Transform Object;
void fixedupdate (Collider col)
{
if(col.gameObject.tag == "DeathFire")
{
Destroy(transform, 3f);
Debug.Log ("Destroy working");
}
}
Any suggestions?
Comment
Thank you but I've tried that already, it doesn't work
Answer by Mhiggs16 · Feb 24, 2018 at 03:19 PM
/*You might need two different scripts depending on your project and objects but you might use a timer and set the time really low.*/
Void OnTriggerEnter (Collider other)
{
If (other.tag == “COL”)
triggeringCOL = other.gameObject;
triggeringCOL.GetComponent().DestroyCOL();
}
/*This would be your second script on the other object.*/
public class COL : Monobehaviour
{
public float timer;
void Update()
{
timer -= 1 * Time.deltaTime;
if(timer <= 0)
Destroy(this.gameObject);
}
void DestroyCOL()
{
Destroy(this.gameObject);
}
}