Question by
JerinDd · Jul 28, 2021 at 04:06 AM ·
waitforsecondsienumerator
Is there a way to wait for a fraction of a second?
For example, what should I do to wait for 9.5 seconds? Yield return new waitforseconds isn’t cutting it and I would be grateful for a way to wait for 9.5 seconds.
Comment
WaitForSeconds should work just fine, but if it isn't working you can go for another approach
public float requiredTime = 9.5f;
float activeTime = 0f;
void Start()
{
activeTime = requiredTime;
}
void Update()
{
activeTime -= Time.deltaTime;
if(activeTime < 0f)
{
//do something
}
}
Your answer
Follow this Question
Related Questions
Help with coroutines 1 Answer
Trying to add a delay to an Instantiate in a For Loop 0 Answers
IEnumerator not working.WaitForSeconds never continiues. 2 Answers
For Loop does two loops at once! 0 Answers
Trying to delay code, nothing works. 2 Answers