Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

WaitForSeconds problem

Discussion in 'Scripting' started by octavian1997, Jul 4, 2015.

  1. octavian1997

    octavian1997

    Joined:
    Sep 3, 2013
    Posts:
    1
    So I'm using a start button to change scenes but i want it to wait wait long enough for a fade out animation to play, but no matter how long I make the second input it only ever waits about 1.5 seconds. Is this a bug? Or am i going about this the wrong way?

    function ChangeScene(){
    WaitForSeconds(8);
    Application.LoadLevel("World");​
    }
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    You need to yield.

    Code (csharp):
    1. yield WaitForSeconds(8);
    Read the scripting reference entry if you aren't sure how to use something.