Ok basically I have a script that toggles a flashlight on the player. The flashlight works fine, however no sound plays. It seemingly should and I’m out of ideas. Here’s the script:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class FlashlightToggle : MonoBehaviour {
private bool FlashlightOn = false;
public AudioClip FlashlightToggleSound;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetButtonDown("FlashlightToggle") && FlashlightOn == false){
FlashlightOn = true;
light.intensity=2;
audio.PlayOneShot(FlashlightToggleSound);
}
else if(Input.GetButtonDown("FlashlightToggle") && FlashlightOn == true){
FlashlightOn = false;
light.intensity=0;
audio.PlayOneShot(FlashlightToggleSound);
}
}
}