My wait for seconds timer is not waiting

I’m trying to run this timer, and I’m pretty sure that I have the syntax correct but it doesn’t seem to be waiting.

Here is the code for the call of the coroutine (these are in the same monobehavour script)

if (swayPosition > twoPI)
{
    swayDirection = !swayDirection;
    swayPosition -= twoPI;
    StartCoroutine(PauseSway());
}

And here is the code for the PauseSway method

    public IEnumerator PauseSway()
    {
        if (!swayPaused)
        {
            swayPaused = true;
            UnityEngine.Debug.Log("started");
            yield return new WaitForSeconds(swayPause);
            UnityEngine.Debug.Log("ended");
            swayPaused = false;
        }
    }

The two things added to the console happen at the same exact time no matter how many seconds I put in for WaitForSeconds. IE: if swayPayse is 3, the console says started and ended both happen on the same second

Nvm, figured it out immedietly, turns out I had swayPosition default as 3 but the game object that uses it had it set to less than a second.

God I am stupid.

Although I would like to know how I mark a thread as resolved, or am I confusing this with steam forums?

1 Like

No, you’re not stupid. You do programming and you develop games, certainly not stupid :slight_smile: Just an ordinary oversight, happens to everyone every now and then.

Well, the forum isn’t really a classical Q&A site. Though some add a tag “resolved” to the thread. But there’s not really a functionality built-in

1 Like