float GetAveragedVolume()
{
float[] data = new float[256];
float a = 0;
audio_source.GetOutputData(data, 0);
foreach (float s in data)
{
a += Mathf.Abs(s);
}
return a / 256;
}
private void Update() { if (microphone.GetAveragedVolume() > 0.01) { inputManager.Shoot(); } //if (Input.GetButton("Fire2")) // inputManager.Shoot(); if (Input.GetKeyDown(KeyCode.R)) { inputManager.RestartGame(); } }