Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

on trigger level end, only if all spawned collectables are collected.

Discussion in 'Scripting' started by BlackVelvet, Apr 9, 2020.

  1. BlackVelvet

    BlackVelvet

    Joined:
    Dec 21, 2013
    Posts:
    7
    Hi everyone, I'm a beginner in coding so I'm probably missing something really simple. I have made a 3d Level that spawns collectables. I want the level end trigger to activate only when all collectables are collected. I have a score system where each collectable has 1 point. It would be great If on a level I could set how much points you have to collect to continue. The player has a script that counts the score.
     
  2. gomgo_unity

    gomgo_unity

    Joined:
    Apr 9, 2020
    Posts:
    4
    In the punctuation script add a:


    Code (CSharp):
    1. // add a "using UnityEngine.SceneManagement"
    2.  
    3. If (Score == 15)
    4.     {
    5.           SceneManager.LoadScene("Game Over");
    6.     } //15 for example
     
  3. gomgo_unity

    gomgo_unity

    Joined:
    Apr 9, 2020
    Posts:
    4
    why my user says that I joined today if I have been in Unity for years???
     
  4. BlackVelvet

    BlackVelvet

    Joined:
    Dec 21, 2013
    Posts:
    7