The question is answered, right answer was accepted
problem to load a scene with SceneManager.LoadScene in Js
Hi everyone !
I am currently working on a 2D game, in which at some point, the character goes to the next level by interacting with a door. The door then checks a boolean in the player script and if true, loads the next level.
But since "Application.LoadLevel" is now obsolete, I am struggling with the new function "SceneManager.LoadScene".
here's my script :
#pragma strict
using UnityEngine.SceneManagement;
public var distance : float;
public var spriteE : Renderer;
public var Player : GameObject;
function Start () {
Player = GameObject.FindGameObjectWithTag("Player");
}
function Update () {
var Dist = Vector3.Distance(Player.transform.position, transform.position);
if (Dist <= 4.2)
{
spriteE.enabled = true;
if (Input.GetKey("e"))
{
if (Player.GetComponent.<haveKey>().GotIt == true) {
SceneManager.LoadScene("endLevel_test");
}
}
}
}
the problem is : The editor keeps showing me the following error message " Assets/decors_test/interactions/EndLevelDoor.js(2,6): UCE0001: ';' expected. Insert a semicolon at the end."
The error seems to be linked to the "using UnityEngine.SceneManagement;" , but I can't seem to get rid of it.
Any ideas ?
Thanks in advance U u U
change "using UnityEngine.Scene$$anonymous$$anagement;" to > import Scene$$anonymous$$anagement;
Follow this Question
Related Questions
Audio Endless Loop c# 1 Answer
How to enable a script in Play-Mode? 1 Answer
ScriptingProblems - Open door with 3 keys 1 Answer
Script error, cannot fix whatsoever! 1 Answer
How do you change UI Text to an int? 4 Answers