Hello,
i want, that the game loads the next level, when my player enter a Triggerbox. But it doesnt work. When i make a button for load the next level it works? The player has the right tag. I have no idea. The script is attached to the box collider of the levelend.
My code:
using UnityEngine;
using System.Collections;
public class LoadNextLevel : MonoBehaviour {
public string levelName ="";
public string tag = "";
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnTrigerEnter(Collider other)
{
if(other.gameObject.tag == tag)
{
Application.LoadLevel(levelName);
Debug.Log("NextLevel");
}
}
void OnGUI()
{
if(GUI.Button(new Rect(300,300,100,100),"NextLvl"))
{
Application.LoadLevel(levelName);
}
}
}