This is a script that is attached to multiple “Chess Pieces” in my game and im calling the setter here.
public class GameManagerChess : MonoBehaviour {
public GameObject colliderObj=null;
public GameManage GameManager;
public int pieceIndex;
public int posX;
public int posY;
// Use this for initialization
void Start () {
this.transform.position = new Vector3(colliderObj.transform.position.x,colliderObj.transform.position.y,colliderObj.transform.position.z);
addToBoardPiecesTable ();
}
void addToBoardPiecesTable(){
GameManager = gameObject.GetComponent<GameManage>();
int pos = pieceIndex * int.Parse(this.tag);
GameManager.setBoardPieces (posX,posY,pos);
}
And this is the setter in the GameManage class
public void setBoardPieces(int posX,int posY,int pos){ _boardPieces[posX,posY]=pos; }
There is a “NullReferenceException: Object reference not set to an instance of an object” error in this line GameManager.setBoardPieces (posX,posY,pos);
Im trying to fill a table in the GameManage class by getting info from all the chess pieces. Im new to C# and unity3d.