Hi! I am trying to use SceneManagement, but I keep getting errors.
I am trying to (using Unityscript) have the level reset after my ball falls a certain distance. I was using Application.LoadLevel and it was working until it wasn't anymore. I got the error saying it's obsolete. Right now, with my code as is I am getting the following error : expecting EOF, found 'import'.
I've tried_
- switching Application.LoadLevel to using SceneManager.LoadScene -
-Adding both using & import UnityEngine.SceneManagement. Although I don't actually know where the code is supposed to go because I am a complete noob and only have the slightest clue of what I'm doing.
The blue lines represent the other spots I tried to place the code.
Any help is appreciated!
Answer by SmomoGame · Oct 19, 2016 at 01:27 AM
Just move line 3 to line 5
make "import" before the variable definition
Additionally to @SmonoGame's recommendation, your if statement is ter$$anonymous$$ated since you've added a semi-colon at the end. This is going to have affects on the LoadScene invocation that you don't want.
Remove your semi-colon on the if statement line to reflect like:
#pragma strict
import UnityEngine.Scene$$anonymous$$anagement;
var maxFallDistance = -10;
function Update(){
if (transform.position.y <= maxFallDistance)
{
Scene$$anonymous$$anager.LoadScene("Game");
}
}
Your answer
Follow this Question
Related Questions
i need help with enemy respawn 0 Answers
Bracket error 1 Answer
Getting error on lap counter script JS 0 Answers
Correct Call function On Gui ? 0 Answers
How to setactive Car Script on writing script on Java on Android platform 0 Answers