Hello,
I'm looking to find out how to get the name of a gameobject then use that name to find that same gameobject.
The way things are set up in my game, the gameobject will go inactive at some point, so I need to find instantiated version of the gameobject and not the prefab. So to the best of my knowledge, I'm stuck using GameObject.Find.
So I have enemy1 with a script on it. (This script will be used on all the enemies).
enemy = GameObject.Find(enemy1); This works great.
However, when I put another copy of the enemy in the scene, it now is enemy1 (1). So the script will find enemy1, but not enemy1 (1).
So I'm wondering if there is a way to have the script find the name of the gameobject, then use that name to find the gameobject.
Something like...
gameObjectName = get.GameObject.name.
enemy = GameObject.Find(gameObjectName);
Thanks!
↧