Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this is the trigger
- using UnityEngine;
- public class endtrigger : MonoBehaviour {
- public GameManagerScript gameManager;
- void OnTriggerEnter ()
- {
- gameManager.CompleteLevel();
- }
- }
- //this is the game manager in a separate script
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class GameManagerScript : MonoBehaviour {
- bool gamehasended = false;
- public float restartDelay = 1f;
- public GameObject completeLevelUI;
- public void CompleteLevel ()
- {
- completeLevelUI.SetActive(true);
- Debug.Log ("LEVELDONE");
- }
- public void endgame ()
- {
- if (gamehasended == false)
- {
- gamehasended = true;
- Debug.Log("GAME OVER");
- Invoke("Restart", restartDelay);
- }
- }
- void Restart ()
- {
- SceneManager.LoadScene(SceneManager.GetActiveScene().name);
- Debug.Log("RESTARTED");
- }
- }
- //my bug report (has a typo)
- https://fogbugz.unity3d.com/default.asp?906597_eqkj43md65n1l36o
- //brackeys forum (I was following his tutorial)
- http://forum.brackeys.com/thread/ontriggerenter-not-working-2/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement