I need the script for when my level ends. I know the basics of how it will work, using a trigger to activate this:
Application.LoadLevel("LevelName");
I just don’t know how to put it into a JavaScript code.
I need the script for when my level ends. I know the basics of how it will work, using a trigger to activate this:
Application.LoadLevel("LevelName");
I just don’t know how to put it into a JavaScript code.
C# script:
using UnityEngine;
[RequireComponent(typeof(Collider))]
public class LoadScene : MonoBehaviour {
public string sceneToLoadName;
protected void OnTriggerEnter(Collider coll) {
if (coll.tag.Equals("Player")) {
Application.LoadLevel(sceneToLoadName);
}
}
}
you should have the collider with isTrigger set as true.
I added a check so that the scene will be loaded only if the object that will activate the trigger has the Player tag on it, but if you don’t need it just delete the if.
On top of that, you need to know that sceneToLoadName has to have the same name of the scene you want to load and that the scene itself must be present in the list “Scenes in Build” contained in the “Build Settings” window.
Yeah I know about all of that. Worked fine, thanks. Now I can just get on with creating the levels.
Enjoy the creation of your game
Will do, thanks.
Creating a game is much harder than I anticipated, but it is enjoyable, and great to see your work pay off to create an actual game.
In case you can’t tell, this is my first one.
so you have to give your best shot !!!