- Home /
Question by
RuiFerreira · Aug 23, 2014 at 06:34 PM ·
javascriptsoundclickpoints
JavaScript: Sound & Points deduct On click Help!
Can anyone help me on this script that I am working on? I'm trying to be able to deduct points from "currentmagic" variable every time I click the left mouse button as well as play a sound when I click it. There are no errors and it doesn't work any help will be appreciated. Thanks!
var currentmagic : int = 100;
var maxmagic : int = 100;
var display_1 : GUIText;
var sound_1 : AudioClip;
var sound_2 : AudioClip;
function update () {
if (Input.GetMouseButton(0)); {
soundaudio();
currentmagic -= 5;
}
if (maxmagic < 5); {
audio.PlayOneShot (sound_2);
}
}
function soundaudio() {
audio.PlayOneShot (sound_1);
}
function OnGUI () {
display_1.text = "Magic " + currentmagic + " / " + maxmagic;
}
Comment
Your answer
Follow this Question
Related Questions
Detect face of cube clicked 4 Answers
Play sound when out of ammo 0 Answers
What is The Javascript name for "Left Mouse Click" 3 Answers
Click to destroy object 2 Answers
I have problems with coding 0 Answers