- Home /
 
 
               Question by 
               JBaBe · Aug 25, 2016 at 08:25 PM · 
                destroycoroutineontriggerenterwaitforsecondsdelay  
              
 
              How can i get this Delay script to work?
i'm trying to get the death of a gameobject to intervene after it is out of the camera view the destroy function works fine but not the waitforseconds!
[1]: /storage/temp/76883-capture3.png
 
                 
                capture3.png 
                (11.1 kB) 
               
 
              
               Comment
              
 
               
              Answer by Jessespike · Aug 25, 2016 at 08:43 PM
 using UnityEngine;
 using System.Collections;
 
 public class score : MonoBehaviour {
 
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.CompareTag("Player")) {
             Destroy(gameObject, 3f); // destroy after 3 seconds
         }
     }
 }
 
                
                
               Next time, copy-paste the code and format it with the 101/010 button.
Your answer