Instantiated Objects dont get their Script referenced properly

I have the problem that all of my Instantiated Objects dont get their Script referenced properly from another Object because they’re name isn’t ,Sprawler" anymore but ,Sprawler(Clone)" . My Question would be how can i reference the Script of my Clones properly. I just need to call a function later on from that referenced script.

SprawlerEnemyAI = GameObject.Find (“Sprawler”).GetComponent ();

This works for my manual placed Object, but changing the Find name to Sprawler(Clone) will make the Function not beeing called. Even though MonoDevelop autocorrects to the Function, meaning that somehow i do reference it right… its just not getting called

There are a few ways, renaming your clone in it’s constructor
this.gameobject.name = “Sprawler”;
Or changing your find to (“Sprawler(clone)”);

BUT I would suggest putting your SprawlerEnemyAI into a list when created:

  1. you don’t have to rely on
    GameObject.Find() and it’s expense.

  2. You have full references and are not
    limited by the hard coded name you
    are using.

  3. It’s a better practice since you are already running into problems. "I can’t rename objects freely, I can’t change my scene objects without breaking this script. I don’t know if these objects actually exist under those names. "

I agree, you should get into the practice of adding your gameobjects into a list should you ever need to be able to reference that object.

GameObject someSprawler = Instantiate(Sprawler);

sprawlerList.Add(someSprawler);