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 /
  • Help Room /
avatar image
0
Question by safak93 · Sep 30, 2015 at 01:29 PM · scorecountergameover

GameOver Score Counter

Hi,

How can I count the score from 0 to the reached score on the GameOver menu?

     public Canvas gameOverMenu;
     public Text score; //Default is 0
 
     public void GameOver(){
         StartCoroutine (OpenGameOverMenu ());
         //score is a static float from the playerscript
         score.text = Player.score.ToString(); //How can I count?
     }
 
     IEnumerator OpenGameOverMenu(){
         yield return new WaitForSeconds (0.8f);
         gameOverMenu.enabled = true;
     }

Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by safak93 · Oct 02, 2015 at 05:27 PM

I made it. Maybe it will help someone.

Here is the script:

     public enum GameState{Playing, GameOver};
     public GameState currentGameState;
     public float waitTime = 1.5f;
     private float currentTime = 0;
 
     public Canvas gameOverMenu;
     public Text score;
 
     //////////////////////////////////////////////////
 
     public void GameOver(){
         StartCoroutine (OpenGameOverMenu ());
         currentGameState = GameState.GameOver;
     }
 
     IEnumerator OpenGameOverMenu(){
         yield return new WaitForSeconds (0.8f);
         gameOverMenu.enabled = true;
     }
 
     public void Update(){
         if (currentGameState == GameState.GameOver && Player.score > 1) {
             currentTime += Time.deltaTime;
             score.text = Mathf.FloorToInt (Mathf.Lerp (0, Player.score, currentTime / waitTime)).ToString ();
         } 
         else if (currentGameState == GameState.GameOver) {
             score.text = Player.score.ToString();
         }
     }

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
avatar image
0

Answer by Ali-hatem · Sep 30, 2015 at 02:24 PM

 public void GameOver()
      {
            if ( Player.score >= 5 )//if that how you enter the player class
            {
                 StartCoroutine (OpenGameOverMenu ());
            }
       }




Comment
Add comment · Show 1 · 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
avatar image safak93 · Sep 30, 2015 at 03:04 PM 0
Share

Thanks for your answer. Unfortunately that's not what I want to do.

If the player dies the function "_menu$$anonymous$$anager.GameOver();" will called and then the GameOver menu will be opened with "StartCoroutine (OpenGameOver$$anonymous$$enu ());". Until here everything works how I want it.

After that there is a score text on the menu to display the reached score - >score.text = Player.score.ToString();. So I want to display the score with a counter. As an example: Lets say the Player.Score is "5" and the player dies. I want to display it, after the GameOver menu is open, with a counter, begins at 0 and stops at 5 -> 1,2,3,4,5.

I hope I could explain it.

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

28 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

Related Questions

PlayerScore prefab in unity gives value in gameover screen as 0, how do I show the final value in GameOver scene? 0 Answers

UI and GUI not updating score? 1 Answer

How can I keep a score counter of how many points the player has collected on the screen? 1 Answer

Showing different objects OnMouseDown 1 Answer

How do you add +1 to a score counter after a destroy script (C#)? 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