Hello. I want to create counter in my 2D game. When player touching object (tree), script add 1 money(for example) to it.
In real counter adding 1 money every frame. I don’t know how to fix this.
May be this problem with code?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextCounter : MonoBehaviour
{
[SerializeField]public static float moneyCount;
Text count;
void Start(){
count = GetComponent<Text> ();
}
void Update(){
count.text = "Money: " + moneyCount.ToString();
}
}