Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class GameOver : MonoBehaviour
- {
- public float restartDelay = 5f; // Time to wait before restarting the level
- public Vector3 gameO; // Isso eu que criei pra uns testes
- public Collision collision;
- Animator anim; // Reference to the animator component.
- float restartTimer; // Timer to count up to restarting the level
- void Awake ()
- {
- // Set up the reference.
- anim = GetComponent <Animator> ();
- gameO.y = 1.5f; // Isso eu que criei pra uns testes
- }
- void Update ()
- {
- if(collision.gameObject.tag == "Cube" ) // Isso eu que criei pra uns testes
- {
- // ... tell the animator the game is over.
- anim.SetTrigger ("GameOver");
- // .. increment a timer to count up to restarting.
- restartTimer += Time.deltaTime;
- // .. if it reaches the restart delay...
- if(restartTimer >= restartDelay)
- {
- // .. then reload the currently loaded level.
- Application.LoadLevel(Application.loadedLevel);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement