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

How make a score system to count a game with teams playing?

Discussion in 'Scripting' started by Nithium, Jun 18, 2016.

  1. Nithium

    Nithium

    Joined:
    May 18, 2016
    Posts:
    7
    Hi! Im trying to make a game where the player has to pick up more coins than the IA controlled object, but i dont know how to script it! Anyone can give a hand here? :(
     
  2. EuanHollidge

    EuanHollidge

    Joined:
    Nov 3, 2014
    Posts:
    69
    Ok so first things first what are you asking for here? The score system or the AI? the AI can be tricky but the score system is easy enough :) How are you planing on displaying the score? On a UI.text? Or something different?
     
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    I suggest you try to write something yourself and post your code here if you get stuck. From the sounds of things, you're needing a lot of help and we can't write your entire script for you.

    An AI script alone can be super complex depending on what it needs to do. The score system is fairly easy, but you need to attempt to set this up before anybody can really help you, as we have no idea how you have things laid out.
     
    Last edited: Jul 3, 2016
  4. Nithium

    Nithium

    Joined:
    May 18, 2016
    Posts:
    7
    Hi everyone! I already scripted the Oponent IA but i kinda confuse how to make count the coins wich he picks up, i just copy the code i used to count on player to the oponent? Im still trying to figure out how compare the score to determine the winner :(.
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    You're going to have to track two variables. One for your player coins and one for your opponent coins. Then, once the round is over, you see which is greater and that player/AI is the winner.
     
  6. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    If you pick up a coin, just add +1 to whatever int your using to count coins. For example:

    Code (CSharp):
    1. public int CoinCount;
    2. public Text CointCountText;
    3.  
    4. void PickCoin()
    5. {
    6.     //first lets count it
    7.     CoinCount += 1;
    8.     //now lets show it
    9.     CoinCountText.text = "Coins" + CoinCount;
    10. }