Hello, so I have my points Script, and I wanted to make it count smoothly like 188 189 190 as count.
And I have a problem trying to resolve this
Please try to help me out here.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ScoreManager : MonoBehaviour {
Animator anim;
public static int score;
private float m_smoothScore;
private float m_smoothScoreVelocity;
private int m_displayedScore = -1;
TextMeshProUGUI text;
public static bool collected;
public float min;
public float max;
public float t;
void Awake()
{
text = GetComponent<TextMeshProUGUI> ();
score = 0;
}
void Start()
{
anim = GetComponent<Animator> ();
collected = false;
}
void Update () {
//smooth score animation
m_smoothScore = Mathf.SmoothDamp(m_smoothScore,(float)score,ref m_smoothScoreVelocity, 0.2f, Mathf.Infinity, Time.deltaTime);
//display the text
int toDisplay = (int)Mathf.Round(m_smoothScore);
if (toDisplay != m_displayedScore)
{
m_displayedScore = toDisplay;
text.text = "Score: " + m_smoothScore;
}
//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);
}
}
}