SOLVED
Hi! My code isn’t working, I will get straight to the problem, here is a screenshot of the error → Imgur: The magic of the Internet
and here is the code to which the error is pointing at:
#pragma strict
var maxFallDistance = -10;
private var isRestarting = false;
function Update ()
{
if (transform.position.y <= maxFallDistance)
{
if (isRestarting == false)
{
ResetLevel ();
}
}
}
function ResetLevel () {
isRestarting = true;
audio.Play ();
Yeild WaitForSeconds (audio.clip.length);
Application.LoadLevel (“Level01”);
}
Help me please!!
Yield
not
Yeild
and use [ code][/ code] tags when pasting code into the forums, sticky at the top of the scripting forum, errors have line numbers, without those tags we can easily see the line numbers…
Achexi
June 29, 2015, 3:21pm
3
Yeild WaitForSeconds (audio.clip.length);
should be Yield
Why you got beef with semicolons?
1 Like
LeftyRighty:
Yield
not
Yeild
and use [ code][/ code] tags when pasting code into the forums, sticky at the top of the scripting forum, errors have line numbers, without those tags we can easily see the line numbers…
Whoops! sorry my bad thank you for the quick response
LeftyRighty:
Yield
not
Yeild
and use [ code][/ code] tags when pasting code into the forums, sticky at the top of the scripting forum, errors have line numbers, without those tags we can easily see the line numbers…
Umm that didn’t fix it, it just says the same error (I did save it, before you ask) D:
the code you posted is the BallHealth script? (asking because there doesn’t appear to be anything relating to health in it… )
audio.Play ();
you don’t appear to have an audio variable declared/initialised… although I wouldn’t have expected a semicolon error for that…
How would I do that in JavaScript?
at the top:
you’d need the audiosource component on the same gameobject… but again, wouldn’t have expected a ; error for that would have expected a null reference exception etc. :blames unityscript for weird erroring:
So would you know any fix on how to get rid of this semicolon error?
Can you post the whole script and use [ code][ /code] UBB tags so its legible?
#pragma strict
var maxFallDistance = -10;
private var isRestarting = false;
function Update ()
{
if (transform.position.y <= maxFallDistance)
{
if (isRestarting == false)
{
ResetLevel ();
}
}
}
function ResetLevel () {
isRestarting = true;
audio.Play();
Yield WaitForSeconds (audio.clip.length);
Application.LoadLevel ("Level01");
}
What are you editing the script in? VS?
Also, in JS with #pragma strict you have to strictly define variables. So “var isRestarting = false;” should be “var isRestarting : bool = false;”…
Theres also no reference to ‘audio’… theres lots of errors in here, your editor probably thinks this is a C# script.
LaneFox:
What are you editing the script in? VS? Likely your environment thinks you’re coding in C#.
Also, in JS with #pragma strict you have to strictly define variables. So “var isRestarting = false;” should be “var isRestarting : bool = false;”…
I’m editing it in notepad++
At a bare minimum you should use Monodevelop.
I have installed Monodevelop but that hasn’t fixed anything