- Home /
Cant hear audio from second camera?
Ok So i have 2 cameras, one for the fps player and one which it switches to once u die. The thing is once I switch and it plays the sound, I cant hear the loose audio. I can still click and shoot my gun and hear THAT audio, but just not the one I want to hear. How can I make it so I can hear that audio that plays when I die? O and once u die it changes to a camera that is placed in front of a billboard saying "You died"
Here script:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class PlayerHealth : MonoBehaviour {
// Start is called before the first frame update
void OnCollisionEnter(Collision col)
{
if(col.gameObject.name == "Enemy")
{
StartCoroutine(Wait());
IEnumerator Wait()
{
yield return new WaitForSeconds(1);
Health --;
}
}
}
public float Health = 100;
public GameObject Player;
public Camera Cam1;
public Camera Cam2;
public GameObject crosshair;
public AudioSource EndAudio;
public AudioListener Camera1;
public AudioListener Camera2;
public Image healthbar;
public Image healthbarBackground;
private void Start()
{
Cam1.enabled = true;
Cam2.enabled = false;
Camera1.enabled = true;
Camera2.enabled = false;
EndAudio.enabled = false;
healthbar.fillAmount = 1f;
}
// Update is called once per frame
void Update()
{
if (Health < 1)
{
healthbar.enabled = false;
healthbarBackground.enabled = false;
EndAudio.enabled = true;
Camera1.enabled = false;
Camera2.enabled = true;
Cam1.enabled = false;
Cam2.enabled = true;
Destroy(crosshair);
EndAudio.Play();
}
}
}
Your answer
Follow this Question
Related Questions
Custom character controller randomly rotates after colliding with an object 0 Answers
How to fix errors on Google play service in unity? 1 Answer
three second timer. 1 Answer
In the ski years you can earn on your game,At what age can you earn on your group 0 Answers
1st Person Character Controller 1 Answer