SFX Scripting

Hello! I happen to be making a horror game and I need help on how to make sfx timing in JavaScript. Here is my code:
function Update () {
if (Input.GetKeyDown(“q”))

AudioSource.PlayClipAtPoint;
}

whenever I type this in, it gives me an error saying this:

C:\Users\D\Documents\New Unity Project 2\Assets\Flashlight sfx.js(13,13): Error BCE0034: Expressions in statements must only be executed for their side-effects. (BCE0034) (Assembly-UnityScript)

I don’t know how to fix it!

You should pass the audioclip instance into that function call…

It looks like you are invoking a method PlayClipAtPoint(…parameter?..). Method’s take parameter’s, and like @liortal explains, you need to pass something into the PlayClipAtPoint method. IntelliSense tells you what to pass in the method if you type this much: “A dialog should pop up telling you what to do”.

AudioSource.PlayClipAtPoint(

Here is some more info on how to use methods:
http://www.w3schools.com/js/js_object_methods.asp

1 Like

oh yes, thank you very much!

1 Like