Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity set active for seconds

public class ActivatorObject : MonoBehaviour
 {
     public GameObject objectToActivate;
 
     private void Start()
     {
         StartCoroutine(ActivationRoutine());
     }
 
     private IEnumerator ActivationRoutine()
     {        
         //Wait for 14 secs.
         yield return new WaitForSeconds(14);
 
         //Turn My game object that is set to false(off) to True(on).
         objectToActivate.SetActive(true);
 
         //Turn the Game Oject back off after 1 sec.
         yield return new WaitForSeconds(1);
 
         //Game object will turn off
         objectToActivate.SetActive(false);
     }
 }
 
PREVIOUS NEXT
Tagged: #unity #set #active #seconds
ADD COMMENT
Topic
Name
2+6 =