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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

How to end game when certain variable reached?

Discussion in 'Getting Started' started by darwazehshaker, Aug 3, 2018.

  1. darwazehshaker

    darwazehshaker

    Joined:
    Aug 3, 2018
    Posts:
    7
    Hello,
    I'm making a strategy game where you rule a nation.
    You can buy things and get money from taxes. However, I want to trigger a new scene/ending when the player's money is 0. Is there a way of doing this?
    Thanks.
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
  3. darwazehshaker

    darwazehshaker

    Joined:
    Aug 3, 2018
    Posts:
    7
  4. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Basically, yeah. I'd imagine this is something you'd want to put in your GameManager script (which is just a script that keeps track of whichever data you need to during the game at all times. IE: Player health and such).

    But before continuing, I'd recommend going through some of Unity's project tutorials and scripting tutorials first. The type of game you want to make sounds like it would require at least intermediate-level of knowledge to create.
     
  5. darwazehshaker

    darwazehshaker

    Joined:
    Aug 3, 2018
    Posts:
    7
    Thanks Again.
    I'll check out the tutorials.
    You assisted me a bunch, I appreciate that.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Where are you adding/subtracting the money? Please show the code you are using (if you have got that far)
     
  7. darwazehshaker

    darwazehshaker

    Joined:
    Aug 3, 2018
    Posts:
    7
    I'm just using regular UI text elements.
    I've already figured it out, thanks for trying to help.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    For the benefit of other readers, can you share your solution?