Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Symbie · May 29, 2020 at 12:06 AM · uiscorepoints

How to make a score screen or something related

I am pretty new to unity and am trying to create a simple game where two players spawn in and run around the map touching little pads. when you touch the pads they change colour to that of the player and are given a point, the player with the most points at the end of the time given (30 seconds) wins. i have this working, now what i want to do is at the end of the 30 seconds is for a screen to pop up saying which player won that round, and then the amount of round wins they have, e.g. 1-0. then i want it to disappear and start another round. how could i do this? These are the scripts i have:

Score Script

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class Score : MonoBehaviour
 {
     public float playerOneScore;
     public float playerTwoScore;
 
     public Text playerOneScoreText;
     public Text playerTwoScoreText;
 
     // Start is called before the first frame update
     void Start()
     {
         playerOneScore = 0f;
         playerTwoScore = 0f;
 
         playerOneScoreText.text = "0";
         playerTwoScoreText.text = "0";
     }
 
     void Update()
     {
         playerOneScoreText.text = playerOneScore.ToString();
         playerTwoScoreText.text = playerTwoScore.ToString();
     }
 }

The Timer script that gives a countdown to the games start and counts down the amount of time left in the round

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class Coutndown : MonoBehaviour
 {
     float timeLeft = 3.0f;
     float gameTimeLeft = 30.0f;
 
     public Text text;
     public Text gameTime;
     public Text playerOneScore;
     public Text playerTwoScore;
 
     public GameObject spawnObject;
     PlayerSpawn spawnScript;
 
     public GameObject playerOne;
     PlayerController playerOneScript;
 
     public GameObject playerTwo;
     PlayerController playerTwoScript;
 
     public bool startGame;
     public bool endGame;
 
     void Start()
     {
         spawnScript = spawnObject.GetComponent<PlayerSpawn>();
         playerOneScript = playerOne.GetComponent<PlayerController>();
         playerTwoScript = playerTwo.GetComponent<PlayerController>();
 
         startGame = false;
         endGame = false;
     }
 
     void Update()
     {
         if (spawnScript.playersSpawned)
         {
             StartCountdown();
         }
         
     }
 
     void StartCountdown()
     {
         timeLeft -= Time.deltaTime;
         text.text = Mathf.Round(timeLeft).ToString();
         if (timeLeft < 1)
         {
             text.text = "GO!";
         }
         if (timeLeft < 0)
         {
             playerOneScript.speed = 10f;
             playerTwoScript.speed = 10f;
             text.text = "";
 
             StartGame();
 
         }
     }
 
     void StartGame()
     {
         gameTimeLeft -= Time.deltaTime;
         gameTime.text = Mathf.Round(gameTimeLeft).ToString();
         if(gameTimeLeft < 0)
         {
             playerOneScript.speed = 0f;
             playerTwoScript.speed = 0f;
 
             gameTime.text = "";
             playerOneScore.text = "";
             playerTwoScore.text = "";
 
         }
     }   
 
 
 }

A script that detects if a player touches its pad and gives them a point/takes away a point

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GetPoints : MonoBehaviour
 {
     Renderer rend;
 
     public GameObject gameManager;
     Score scoreScript;
 
     public bool bluePad;
     public bool redPad;
     public bool whitePad;
 
     public bool playerOnePoint;
     public bool PlayerTwoPoint;
 
     void Start()
     {
         rend = GetComponent<Renderer>();
 
         scoreScript = gameManager.GetComponent<Score>();
 
         bluePad = false;
         redPad = false;
         whitePad = true;
         playerOnePoint = true;
         PlayerTwoPoint = true;
 
 
     }
     void OnTriggerEnter(Collider collider)
     {
         if (collider.gameObject.tag == "PlayerOne" && whitePad == true)
         {
             whitePad = false;
             bluePad = true;
 
             rend.material.SetColor("_Color", Color.blue);
 
             playerOnePoint = true;
 
             if (playerOnePoint)
             {
                 scoreScript.playerOneScore++;
                 playerOnePoint = false;
             }
 
         }
 
         if (collider.gameObject.tag == "PlayerOne" && redPad == true)
         {
             redPad = false;
             bluePad = true;
 
             rend.material.SetColor("_Color", Color.blue);
 
             playerOnePoint = true;
 
             if (playerOnePoint)
             {
                 scoreScript.playerOneScore++;
                 scoreScript.playerTwoScore--;
                 playerOnePoint = false;
             }
         }
 
         if (collider.gameObject.tag == "PlayerTwo" && whitePad == true)
         {
             whitePad = false;
             redPad = true;
 
             rend.material.SetColor("_Color", Color.red);
 
             PlayerTwoPoint = true;
 
             if (PlayerTwoPoint)
             {
                 scoreScript.playerTwoScore++;
                 PlayerTwoPoint = false;
             }
 
         }
 
         if (collider.gameObject.tag == "PlayerTwo" && bluePad == true)
         {
             redPad = true;
             bluePad = false;
 
             rend.material.SetColor("_Color", Color.red);
 
             PlayerTwoPoint = true;
 
             if (PlayerTwoPoint)
             {
                 scoreScript.playerOneScore--;
                 scoreScript.playerTwoScore++;
                 PlayerTwoPoint = false;
             }
 
 
         }
     }
 
 }
 







Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Map-Builder · May 29, 2020 at 12:55 AM

Hi, try to understand those scripts and modify them for your needs.


PS: noone will answer to,

"Hi, I wanna do this and I have those scripts" and BAM code bulk


Everything I see here is kinda simple but linked to scene gameobjects, so ....

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

219 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Score counter breaking after adding points 2 Answers

Score increases based on number of collisions at time of kill, not on single kill.,Score increases based on collisions at time of death, not based on single kill. 1 Answer

Scoresystem wont function correctly 0 Answers

How to change scoreInputField to get a score from another script/Scene 0 Answers

Score Multiplier by Time 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges