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