Quantcast
Channel: Questions in topic: "count"
Viewing all articles
Browse latest Browse all 187

Problem with Checkpoint counting

$
0
0
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.

Viewing all articles
Browse latest Browse all 187

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>