im trying to make when my player hit the end load the scene 5 seconds after here is my script
For instance :
var myLevel : String;
function OnCollisionEnter (myCollision : Collision) {
LoadAScence (); //Your new function
}
function LoadAScene () {
yield WaitForSeconds (5); //To make it wait for 5 seconds before continue
Application.LoadLevel (myLevel);
}
but i got this errors
Assets/NewBehaviourScript.js(1,4): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/NewBehaviourScript.js(1,5): BCE0044: expecting EOF, found ‘instance’.
This is what you get for blindly copy-pasting other people’s scripts without understanding anything about coding. I’ve told you not to do that! The problem is because you copied over the ‘For instance:’ line, which is obviously telling you that the code after it is supposed to be an example. Don’t just copy the ‘For instance:’ bit too! It’s not legal code, and, moreover, it doesn’t even make sense!
As for the scene loading bit, you should be calling it like this instead-
StartCoroutine(LoadAScene());
because it has an asynchronous component- the ‘WaitForSeconds’ bit. You need to split it off into a different coroutine, otherwise it will try to freeze your game for 5 seconds! (it won’t, by the way, it’ll just silently fail, but that’s just because it’s well designed)
Always, check for spelling errors. Computers are absolutely draconian about this stuff- if you put one character out of place the entire program will fail.