public float breaktime = 20f;
if (Time.realtimeSinceStartup == breaktime)
{
gameStop();
breakCard.SetActive(true);
breakText.enabled = true;
Ok.enabled = true;
Oktext.enabled = true;
}
so basically there is a float breaktime and i have set the breakcard, breaktext and other things disabled in the awake. when i am trying to enable it using this it is not working.
You’re never going to see that condition met as-is.
Rather, there’s probably a 1-in-a-few-trillion chance you’ll see it happen, which means you’re never going to see that happen. On a given frame, you wouldn’t see EXACTLY 20 seconds having passed. Maybe 20.0001 seconds if you’re “lucky”, but that’s still not 20.
Since this is meant to be a one-time checkpoint, you’ll just need to treat it as such instead:
bool trigger20s = false;
// ...
if(!trigger20s && Time.realtimeSinceStartup >= breakTime)
{
trigger20s = true;
// etc.
}
I see that the Unity documentation says it returns a float but their code example uses double. Just tried this myself and it makes no difference. I assume C# can cast between single and double without an issue. So my earlier suggestion of “Use a Double” was incorrect. Apologies…