Comparing AudioSource.time with float doesnt work.

When I check if AudioSource.time is equal to a float, it doesnt turn out true all the time.
Example:

if (Mathf.Approximately(AudioSource.time , 5.400))
{
Debug.Log(“true”);
}
Would turn out true but

if (Mathf.Approximately(AudioSource.time , 6.400))
{
Debug.Log(“true”);
}
would not turn out true.

You are checking time in update, right? THis happen because update happens in certain frame rate depending on your FPS (frames per seconds).

Lets, say, you are running on 60fps, so your frame rate is 1s/60 = 0.017s.

So you ask for comparision when AudioSource.time is let say 5.3900 and next frame when your time is 5…407. So your frame almost never happen exactly in 5.400.

You can only check if time is greater or less than desired value.