- Home /
This question was
closed Jun 27, 2013 at 02:24 AM by
AlucardJay for the following reason:
Question is off-topic or not relevant
Question by
Yoscaron · Jun 26, 2013 at 07:08 PM ·
soundflashlightmakeon and off
How can I make a script for a flashlight that make sounds when it turns on and off?
Comment
Best Answer
Answer by greatwhiteshark17283 · Jun 26, 2013 at 07:12 PM
Try this:
var key : String;
var onSound : AudioClip;
var offSound : AudioClip;
function Update(){
if (Input.GetKeyDown(key)){
if (light.enabled == true)
light.enabled = false;
audio.PlayOneShot(offSound);
else
light.enabled = true;
audio.PlayOneShot(onSound);
}
}
Follow this Question
Related Questions
Flashlight sound script won't work 1 Answer
How to make script for FlashLight Sound , ON and OFF. 2 Answers
Flashlight Battery Error No definition 1 Answer
How to pickup flashlight with "E" key ? 1 Answer
Play audio from directory? 0 Answers