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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

C# scoring system

Discussion in 'Scripting' started by Frankzillaman, Jun 13, 2015.

  1. Frankzillaman

    Frankzillaman

    Joined:
    Mar 20, 2015
    Posts:
    22
    Hello, i have a scoring system set up on my runner, with triggers over and under every obstacle to give the player points when they hit it. There are a few issue is i am currently running into, and i am looking for a little guidance. First issue is, although i have my trigger set up under and over each obstacle, to add points when player hits it, i cant seem to turn off the points when the player does not do the obstacle right? So, what i mean is the player can still get points when hitting the trigger although they did not correctly avoid the obstacle. Second issue is, i cannot seem to get a multiplier to work. I want the multiplier to start as soon as the player correctly avoids 5 obstacles in a row. Again i appreciate any and all help. Thx in advance.
     
  2. carljohnfred

    carljohnfred

    Joined:
    Dec 28, 2012
    Posts:
    31
    You could add a trigger on the obstacle and check to make sure the player did not hit the obstacle after the player passes it. If so, add the points.

    For the multiplier, it's just a matter of adding a variable and multiplying by it when adding points. It would start at 1 and reset to 1 when an obstacle is hit. You could have another variable count the number of obstacles avoided in a row and at certain intervals, increase the multiplier variable.