public class MyScript : MonoBehaviour
{
float timer:
void Update()
{
// If condition is false, reset timer and return out. Replace condition with your logic.
if (!condition)
{
timer = 0.0f;
return;
}
timer += Time.deltaTime:
if (timer > 0.5f)
{
// do stuff
timer = timer - 0.5f; // reset timer
}
}
}