Quantcast
Channel: Questions in topic: "twice"
Viewing all articles
Browse latest Browse all 70

Adding more points than needed !

$
0
0
Hello I created a point system which is working fine, but I have some issues. ***The main thing here that some times I have twice amount of points (1000 points) instead of normal (500 points) and I don't understand why.*** So what did I miss or go wrong? Here is some scripts. First is on Collectible item. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Collectibles : MonoBehaviour { public int scoreValue; void OnTriggerEnter2D (Collider2D col) { if (col.gameObject.layer == LayerMask.NameToLayer ("Player")) { ScoreManager.score += scoreValue; ScoreManager.collected = true; } else { ScoreManager.collected = false; } } } The second one is for UI system on the screen which shows the score. using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class ScoreManager : MonoBehaviour { Animator anim; public static int score; TextMeshProUGUI text; public static bool collected; public float min; public float max; public float t; void Awake() { text = GetComponent (); score = 0; } void Start() { anim = GetComponent (); collected = false; } void Update () { text.text = score + " PTS"; if (score > 0) { anim.SetBool ("Points", true); } if (collected == true) { t = Time.time; text.fontSize = Mathf.Lerp (min, max, t); collected = false; } else { t = Time.time; text.fontSize = Mathf.Lerp (max, min, t); } } } ***Please try to help :)***

Viewing all articles
Browse latest Browse all 70

Trending Articles



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