hi, does anyone know how to load a level once the player collides with something, i tried to script it in .JS but it doesnt work....
(Everything under here is my code!!)
var LevettoLoad : String;
function OnCollisionEnter (Collison : Collision)
{
if(Collison.gameObject.tag == "Player")
{
Application.LoadLevel(LevettoLoad);
}
}
system
2
hello. this worked for me. here is the code:
private var NL = false;
function OnControllerColliderHit(hit:ControllerColliderHit)
{
if(hit.gameObject.tag == "NextLevel")
{
Debug.Log( hit.gameObject.tag );
yield WaitForSeconds (3);
NL = true;
}
}
function LateUpdate()
{
if(NL)
{
Application.LoadLevel(0);
NL=false;
}
}
this code works just fine for my tank game. here you go :)
before you try it you need to check this to:
1: be sure to set the tag right !!! (spelling also)
2: be sure to set the level you want to load to the number 0 in the build settings under file.
if you did that than it should work.