- Home /
Unable To Fix A Simple Coding Error (Script Included)
Hya guys! I want to add a sound whenever spacebar is pressed but my console tells me I'm missing a closing quotation mark. This is what I have so far...
if (Input.GetKeyDown(:"spacebar")); { audio.Play(/Users/Reilly/RiverProject/Coding Test/Explosion/Assets/TestSoundFX.aif) }
If you can figure out where it needs to be inserted, PLEASE tell me.
Answer by Eric5h5 · Oct 30, 2012 at 01:23 AM
It's not a quotation mark you're missing; that code is unfortunately quite wrong in a number of ways. You don't use a colon in GetKeyDown, nor is "spacebar" valid, and you don't write a hard drive path for an audio file in Play (or anywhere). I think you need to read the docs...GetKeyDown tells you how to use that, and likewise for AudioSource.Play.
Your answer
Follow this Question
Related Questions
How can I convert this code to Unity Android? 1 Answer
SCRIPT NOT WORKING 2 Answers
Mesh Inertia Tensor? 1 Answer
No appropriate version of 'UnityEngine.Object.Instantiate. Please Help :( 1 Answer
The code is giving me errors 1 Answer