Now this is a strange one, I’ve run into this error even though to my mind I’m not doing anything wrong. I’m not for instance getting any syntax errors in my IDE when I write the code.
The error is:
NullReferenceException: Object reference not set to an instance of an object
Model.InitActorRelatedModels (Int32 x, Int32 y, System.String name) (at Assets/Model.cs:42)
Grid.CreateActorUnit () (at Assets/Grid.cs:78)
Grid.Awake () (at Assets/Grid.cs:33)
public void CreateActorUnit(){
GameObject act = (GameObject)Instantiate(actorPrefab, new Vector3(1.513628F, 0.0F, 0.4837152F), Quaternion.identity);
act.renderer.material.color = new Color(2.55F, 0.21F, 0.0F);
actorUnits [0] = act;
model.InitActorRelatedModels (1, 1, "hero"); //->code starts here
}
public void InitActorRelatedModels(int x, int y, string name){
gmodel.InitGridModel (x, y);
actors.ChangeData (x, y, name);
}
public void InitGridModel(int x, int y){
gridModel [x, y] = 1;
}
Any help would be greatly appreciated.