Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float startTime;
- int numTreasures;
- int collected = 0;
- bool levelComplete = false;
- GameObject player;
- public float levelBottomY = -10.0f;
- void Start()
- {
- // Take note of level start time. Time.time is seconds since program startup
- startTime = Time.time;
- // Count treasures in level
- GameObject[] treasureObjects = GameObject.FindGameObjectsWithTag("Treasure");
- numTreasures = treasureObjects.Length;
- // Store player game object, needed for falling check
- player = GameObject.FindWithTag("Player");
- }
- void Update()
- {
- // Destroy player gameobject if fallen below level. The player variable goes null automatically
- if (player != null && player.transform.position.y < levelBottomY)
- {
- Destroy(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment