destory object not variable
think im getting my wires crossed when storing and destroying objects.
get this error:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. grid.objGridSize () (at Assets/scripts/grid.cs:119) grid.hit (System.String hitObjString) (at Assets/scripts/grid.cs:109) grid.Update () (at Assets/scripts/grid.cs:80)
from this:
// Something has been hit
public void hit(String hitObjString){
GameObject hitTile = GameObject.Find(hitObjString);
storePosition hitPos = hitTile.GetComponent<storePosition>();
if( hitTile.tag == "tile"){
objGrid[hitPos.x,hitPos.y] = nullTile;
Destroy(hitTile);
}
}
I'd add a Debug.Log() in there to make sure it's not getting called multiple times for the same object.
Your answer
Follow this Question
Related Questions
GameObject not destroyed when stopping 0 Answers
How to get access to variable from another script without knowing script's name c# 2 Answers
Novice Question: Assigning GameObject properties efficiently. 1 Answer
Access another object's variable 1 Answer
storing velocity and temporarly using it 0 Answers