|
So here's my script (UnityScript): I was hoping this would let me play a sound when I press the down arrow button (the audioclip is on the same game object as this script). Instead, the audio clip is playing indefinetly without me pressing anything. Can anybody help me fix this script so that it will allow me to preform what I want? Sorry, I'm really new, so don't be too hard on me.
(comments are locked)
|
|
Thanks, this is my script: var yourAudioClip : AudioClip; function Update () { if(Input.GetButtonDown) { audio.PlayOneShot(yourAudioClip); } }
(comments are locked)
|
|
Thanks, this is my script: var yourAudioClip : AudioClip; function Update () { if(Input.GetButtonDown) { audio.PlayOneShot(yourAudioClip); } }
(comments are locked)
|
|
GetButtonDown is called in the frame you press a button, as opposed to GetButtonUp, which is called when the button is released. It is not connected to the arrow keys. As it is now, it doesn't make sense, since you don't specify which button you want to use.
(comments are locked)
|

I just edited your question and now I notice the line "if(Input.GetButtonDown)". This is not correct, sorry if I erased the correct one (I'm not sure)