Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

WaitForSeconds not working

Discussion in 'Scripting' started by ClaysingProductions, Aug 26, 2018.

  1. ClaysingProductions

    ClaysingProductions

    Joined:
    Jul 18, 2018
    Posts:
    39
    Hello,

    my code for WaitForSeconds is not working.

    Code (CSharp):
    1. isJumped = true;
    2. new WaitForSeconds(2);
    3. isJumped = false;
    if I do
    Code (CSharp):
    1. yield return new WaitForSeconds(2);
    it will do red lines under the Update function

    if you help me it would be very pleased!

    Begames
     
  2. ClaysingProductions

    ClaysingProductions

    Joined:
    Jul 18, 2018
    Posts:
    39
    moderators if u see this please remove the thread I really random have an idea for a alternative
     
  3. zotey

    zotey

    Joined:
    Nov 14, 2012
    Posts:
    26
    Where are you calling this code? This should be called inside of an IEnumerator.
     
    MisterSkitz likes this.
  4. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    IEnumerator for the win! :p
     
    zotey likes this.
  5. D-P-G

    D-P-G

    Joined:
    Feb 26, 2016
    Posts:
    37
    Also you will the to use StartCoroutine() function to call the IEnumerator
     
    zotey likes this.