I made a coin collecting system that increases the number on a counter when the player comes in contact with the "coin" > sphere. I used Debug.Log to make sure that the counter works. It does. However, When I use TextMeshPro to display that value, it is stuck at zero.
public float moneyStart;
public float unit;
public float moneyNow;
public float displayedMoney;
private TextMeshPro textsss;
void Start()
{
TextMeshPro textsss = GetComponent<TextMeshPro>();
}
void OnCollisionEnter(Collision C_Info)
{
if (C_Info.collider.tag == "Currency")
{
displayedMoney = moneyNow + unit;
textsss.text = displayedMoney.ToString("0");
}
}
Visual for the counter stuck at zero
The script is in the TextMeshPro Element
- Am I using TextMeshPro correctly?
- How can I use it better?
- Are there any errors?
- How do I fix it?