A lot of similar questions and answers but I can’t make this work. This error keeps showing up no matter what:
“An object reference is required to access non-static member CoinsCounter.Coins”
I have a Class Named Collect, which contains a public variable called Coin, this variable increases by 1 every time the player collides with an object using this script.(I guess so far this works because I can see the print on my console).
Now, the problem is that I have a GuiText and I want to use it to count and see the number of coins that I am collecting on my HUD.
I created a Class called CoinsCounter, drag it to my GuiText and inside it I have this piece of code:
using UnityEngine;
using System.Collections;
public class CoinCounter : MonoBehaviour {
// Update is called once per frame
void Update () {
guiText.text = Collect.Coin;
}
}
I just want the GuiText to change the “0” value to the number of coins I am picking up.
Any idea?
Thank you very much for your time !!!