Search Unity

Coroutines?

Discussion in 'Scripting' started by GamesOnAcid, Feb 14, 2016.

  1. GamesOnAcid

    GamesOnAcid

    Joined:
    Jan 11, 2016
    Posts:
    283
    Code (JavaScript):
    1. var triggered = false;
    2. function Update()
    3. {
    4.     if(triggered == true)
    5.     {
    6.         StartCoroutine(WaitCoroutine(1));
    7.     }
    8.     if (distance <= 3)
    9.     {
    10.         sanityGUI.currentSanity = sanityGUI.currentSanity + sanityDamage.scarePercent;
    11.         triggered = true;
    12.         AudioSource.PlayClipAtPoint(ScareSound, enemy.position);
    13.     }
    14. }
    I want to make a proper coroutine, but I can't figure out how. Can anyone help me here?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    Abhinav91 and LeftyRighty like this.