- Home /
Scene Audio Script Error
Ok so I have a on collision play audio next scene script but the audio isn't playing. Can you help?
var levelToLoad : String;
var isQuitButton = false;
var select : AudioClip;
var choose : AudioClip;
function OnTriggerEnter(hit : Collider)
{
audio.PlayOneShot(choose);
//load level
Application.LoadLevel("1");
}
Did you edit your question? As soon as I answer. The question changed...
Dude... don't change the question like that once it's answered. Now my pending answer is useless to you AND anyone else who comes along. $$anonymous$$ake a new question.
No actually I figured out on my own just about immediately after I posted but I had a similar problem among similar lines.
Answer by kspiel · Aug 17, 2012 at 03:26 PM
The issue is the first line in the file... you are trying to declare a variable but you are calling a function. I'm not sure what it is exactly that you're trying to do.
Application.LoadLevel() is a static function that takes a single argument that is the name, or ID, of the level you want to load. I presume that it is the level you want to hold in a variable. Yes?
So... in that case...
var currentLevel = "1";
Application.LoadLevel( currentLevel );
Answer by Jessespike · Aug 17, 2012 at 03:14 PM
Here is my error:
(1,16): BCE0043:Unexpected token: ..
var Application.LoadLevel("1");
Error tells you whats wrong. LoadLevel is a function, but you are trying to use it like a variable. Comment out the first line.
Edit: To answer your new question.. The var choose is either undefined or your Colliders aren't triggering correctly.