Audio won’t play even if gameover is true, if i attach it to when pressed D, or start clip plays, but when it is attached to if(gameover==true) or damage>6 and statements are true (I checked that they are true) it won’t play.
public Animator anim;
public int damage=0;
public bool gameover;
public bool busted;
public AudioSource clip;
public int car;
public GameObject gameObject;
public AudioSource clipp;
public bool played = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (gameover == true) {
if(played=false){
clipp.Play();
played=true;
}
}
car = GameObject.Find ("mastergame").GetComponent<master> ().carr;
if (car == 1) {
gameObject.SetActive (false);
}
if (damage > 6) {
gameover=true;
}
busted = GameObject.Find ("Audi").GetComponent<ruchauta> ().busted;
gameover = GameObject.Find ("Audi").GetComponent<ruchauta> ().gameover;
if (Input.GetKey (KeyCode.E)) {
Application.LoadLevel("0");
}
if (damage <= 6&&busted==false) {
if (Input.GetKey (KeyCode.D)) {
transform.Translate (Vector2.right * speed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.A)) {
transform.Translate (-Vector2.right * speed * Time.deltaTime);
}
}
}