Problem with object.getvalue().Length

In my game there are a lot of enemy, and i want to identified for each enemy where are the other enemies. I find they by:

string MyName, OtherName;
GameObject TryName;
TryName = (GameObject.FindGameObjectsWithTag(“Enemy”));
OtherName = TryName.GetValue(0).ToString();
MyName =;

Debug.Log(MyName + " " + OtherName);
Debug.Log(MyName.Length + " " + OtherName.Length);

but when i want to use the name of the other enemy, the string OtherEnemy is much longer as it should be.


Can anyone help me with this?

using TryName.GetValue(0); you are getting the value in index 0 which is a gameobject
because your TryName is an array of gameobject.

doing .ToString() on a gameobject will return what kind of type it is.
Hence showing you: UnityEngine.GameObject

you will have to do OtherName = TryName.GetValue(0);