I have set up a counter to display a “3, 2, 1, GO”. Once it’s running and counting down, no sound plays fully until it gets to the end of the If and Else statement. Here’s the script I’m using:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class countDown : MonoBehaviour {
// Use this for initialization
void Start () {
}
public AudioSource cdSound1;
public float timeLeft = 4f;
public Text displayText;
public float checker;
void countdownSound() {
if (timeLeft >= 3) {
displayText.text = "3";
cdSound1.Play(0);
} else if (timeLeft >= 2) {
displayText.text = "2";
cdSound1.Play(0);
} else if (timeLeft >= 1) {
displayText.text = "1";
cdSound1.Play(0);
} else if (timeLeft >= 0) {
displayText.text = "G O";
cdSound1.Play(0);
}
}
// Update is called once per frame
void Update () {
timeLeft -= Time.deltaTime;
countdownSound();
}
}