- Home /
Question by
John-Lisenby · Jun 25, 2015 at 10:50 PM ·
c#time.deltatime
Playing clock ticking sound
Hello,
I am trying to play a clock ticking sound every second until the round timer = 0. I am not sure how to write the code.
Here what I have sofar.`if (roundTimer > 1) { audio.PlayOneShot(timerTickAudio, 0.30f); Debug.Log("Play timer tick"); }`
I know I need to use time.detatime somewhere.
Thanks for the help.
John
Comment
Answer by DoubleIsLoveDoubleIsLife · Jun 26, 2015 at 06:48 AM
C#
float timer = 1f;
public float roundTimer = 60f;
void Update() {
timer -= Time.Deltatime;
if(timer <= 0 && roundTimer > 0) {
audio.PlayOneShot(timerTickAudio, 0.30f);
timer = 1f;
roundTimer -= 1f;
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why is my Mathf.Movetowards Coroutine executing instantly? 2 Answers
Time.deltaTime doesn't return number of seconds passed 1 Answer
Time.deltaTime using Hindi numbers? 1 Answer