Hi folks,
i made a little battleship game (with Monsters) and for animation i have a animator on each Cell with should start if there is a missed shoot (simple draw a black hole on the tile).
Now i use the Gameobject name as a variable to select the right Gameobject and start the animation:
Debug.Log("Missed: "+ dragScript.targetArray[sliderXval,sliderYval]);
GameObject cell_hit = GameObject.Find(dragScript.targetArray[sliderXval,sliderYval]); //targetArray contains the Grid Field name
cell_hit.GetComponent <Animator>().SetBool("hit",true); // with this i get the error -> no Animator on Gameobject
Debug.Log(dragScript.targetArray[sliderXval,sliderYval]);
//grid90.GetComponent <Animator>().SetBool("hit",true); // with this and drag drop the GameObject in Inspector it is working
With the 2 commands “gameobject.find” and Get Component Set Bool i receive the error:
Which is strange since all cells have the same animator attached to their gameobject, and when i debugged it by selection the gameobject directly with the inspector → it is working without problems.
[SerializeField] GameObject grid90;
btw. i searched for similar issues first and if i missed any information to help please give me a hint.
Thanks
Kristian