Okay so I have my score.
And collectibles which have 500 points each
***I want them to count smoothly, like 001 002 ... 499 500 (like so but faster of course :) )
But for now i just have instant count which adding the score.***
Please help me on this, here is my script of ScoreManager.
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);
}
}
}
And the second which is on my Collectible objects:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collectibles : MonoBehaviour {
public int scoreValue;
public bool alreadyScored;
void OnTriggerEnter2D (Collider2D col) {
if (col.gameObject.layer == LayerMask.NameToLayer ("Player")) {
if (alreadyScored)
return;
alreadyScored = true;
ScoreManager.score += scoreValue;
ScoreManager.collected = true;
} else {
ScoreManager.collected = false;
}
}
}
↧