How do I make it to where when I roll a 3d ball into an object it loads the next scene?
In JavaScript:
#pragma strict
//YOU MUST HAVE THIS FOR IT TO WORK
import UnityEngine.SceneManagement;
//This will let you use it on many objects and can select what level you want
var levelToLoad = 1;
//Take note of the 2D in the OnTriggerEnter. It's important when using 2D colliders.
function OnTriggerEnter2D(other:Collider2D)
{
if(other.gameObject.name == "Player")
{
SceneManager.LoadScene(levelToLoad);
}
}
Look up the UnityEngine.SceneManagement class. You’ll be using methods from that. So in the ball’s OnTriggerEnter event, check if it is the correct trigger, then call SceneManager.LoadScene(“name of your scene in the build settings window”).
void OnTriggerEnter (collider other) {
// make a tag for the TriggeredBlock
if (other.CompareTag(“Trigger”)) {
//move to target scene
Application.LoadLevel ();
}
}