Quantcast
Channel: Questions in topic: "get"
Viewing all articles
Browse latest Browse all 215

Getting the name of a gameobject, then using that name to find it.

$
0
0
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!

Viewing all articles
Browse latest Browse all 215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>