Hi. first of all i’m beginner to coding and also beginner to unity.
i’m using c# and i have a question about WaitForSeconds(float seconds) and WaitForSecondsRealtime(float seconds) . as you know they suspend the coroutine execution for the given amount of seconds. my question is about this float parameter that seems it only have to be a positive number like:
yield return new WaitForSeconds(3.0f); //it waits for 3 second
yield return new WaitForSeconds(0.5f); //it waits for 0 point 5 seconds
same as for WaitForSecondsRealtime.
i’v never thought about negative numbers till now. because i thought i’ll get an error with the YOU HAVE TO USE ONLY POSITIVE NUMBERS description. but i’m checking them now and they magically accept negative number. in my script i play with a variable, then i give it to WaitForSeconds float parameter. sometimes somehow my variable changes to negative(not important how, don’t talk about it please). what happens to yield return new WaitForSeconds(parameter) if its parameter is a negative number? for example:
yield return new WaitForSeconds(-20.0f);
or
yield return new WaitForSeconds(-1.5f); //same as for WaitForSecondsRealtime()
i used the both lines above and nothing happened.(it’s like unity MonoBehaviour or C# or something else is changing it to 0 ). tell me is that true?? if so then i shouldn’t be worry but for what purpose and why WaitForSeconds() and WaitForSecondsRealtime() accept negative number?
I welcome and appreciate any help