Hey guys! I need help. I made a simple level and I want my character to collide with the "end point" (a simple cube) and go to the next level. Lots of scripts hate me and I want a script that makes me move to next level. I tried this one:
OnCollisionEnter()
{
application.LoadLevel();
}
and that didnt work.
Can you give me a script that makes me move to the next level please. (Also: should my character have anything special attached to him like a rigidbody???)
first you should add the scene to the list of scenes in file/build settings... menu. check the is trigger property of your character's collider. add a collider and a rigidbody to the box (end point).
in rigidbody properties check the is kinematic property.
then you can write
function OnTriggerEnter ()
{
Application.LoadLevel ("scenename");
}
You have to specify the level to load in Application.LoadLevel. Also you have to write "Application" correctly (not "application"). You need a rigidbody if you want to have collisions.
Here's a completed script allowing you to set the next scene in the inspector. Make sure the plane/object you walk in to has "Is Trigger" marked. No rigidbody necessary.
//Script to revert winning player back to main menu
var levelToLoad : String;
function OnTriggerEnter(hit : Collider)
{
Application.LoadLevel(levelToLoad);
}//END FUNCTION ONTRIGGERENTER
@ntawesome pickle
If the new level starts loading when starting your scene, than that probably means that the player already is touching an trigger collider. You could specify the object you want by adding an if statement.