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 /
This question was closed Sep 06, 2016 at 11:15 AM by Zythus for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by Zythus · Nov 23, 2015 at 08:18 PM · unity 5scorecountcheckpoints

Problem with Checkpoint counting

I've made Checkpoint system, where a plane goes through rings and checkpoints are counted. It was done with OnGUI.

Recently I came across one of the Unity tutorials: http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/creating-a-jewel-miner-game

It crossed my mind that using UI -> Text was better than coding everything manually with OnGUI. I guess it would be more convenient and simpler to modify if I really wanted to do that in the future.

The problem is as follows: GameManager that is attached to Canvas on the right hand side shows CheckPointCount and TotalCheckpointCount correctly on any particular level. On the other hand on-screen checkpoint count is not changing it's numbers. It's always 0/2 with 2 being the amount of Checkpoints on the level. It was done with UI -> Text, scripts are attached. I think it's a problem with code.

Excerpt of code from GameManager.cs:

 void Start()
     {
         //Amount of checkpoints = Amount of checkpoints from parent folder
         TotalCheckpointCount = CheckpointParent.transform.childCount;
         CheckpointText.text = ("Checkpoints: " + CheckpointCount + "/" + TotalCheckpointCount);
     }
 
      //Checkpoint iteration
      public void AddCheckpoint()
     {
         CheckpointCount += 1;
         CheckpointText.text = ("Checkpoints: " + CheckpointCount + "/" + TotalCheckpointCount);
     }

And excerpt of code from Player.cs, when player is colliding with object:

  if (other.transform.tag == "Checkpoint")
         {
             manager.CheckpointCount += 1;
             Destroy(other.gameObject);
         }

I think I should do something with that CheckpointCount in Player.cs, but I'm not exactly sure how to tackle this. Change it with a reference to the AddCheckpoint class from GameManager perhaps? Any ideas would be greatly appreciated.

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

  • Sort: 
avatar image
0

Answer by Mich_9 · Dec 01, 2015 at 05:07 AM

What is the manager variable in Player.cs? Is a reference to the GameManager class? If so just call AddCheckpoint like this:

manager.AddCheckpoint();

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

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Score value in GameOver screen is 0 instead of final value from the Game Level scene(used PlayerPrefs), how do I display the final value from Game Level scene in the GameOver scene? 1 Answer

How to count child dynamically? 1 Answer

Why is my game not working properly? 0 Answers

Adding "score" from a game to a counter in menu scene 0 Answers

Getting variable from script while keeping other code from it 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