Ok, so I’ve tried every way I possibly know of to fix this issue but I’ve gotten nowhere. I thought GetComponent would fix this but it’s not. The error is caused by the debug log message.
using UnityEngine;
using System.Collections;
public class Block : MonoBehaviour {
public Player player;
public int hp;
public int id;
public int moneyGet;
// Use this for initialization
void awake () {
player = (Player)GameObject.FindGameObjectWithTag ("Player").GetComponent (typeof(Player));
}
// Update is called once per frame
void Update () {
}
public void DamageBlock (int loss) {
hp -= loss;
if (hp <= 0) {
Debug.Log(player.moneyEarned);
gameObject.SetActive (false);
}
}
}