I try to reference a variable in another script and it comes back as 0, no idea why, here’s my code
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.tag == "candy")
{
candyKainz++;
other.gameObject.GetComponent<Candycaine>().collected();
}
}
public class Counter : MonoBehaviour {
public Text numeber;
public Characterbehavior h;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
numeber.text = h.candyKainz + "/100";
}
}