Finding a prefab in after respawn

Hey,

I have a question how i can find a prefab after it spawned.
Should i use in the update function GameObject.Find() to check if it is there or not ?

Or is there another method , a better one ?

Regards,

LifeArtist

This depends on the nature of your code and your application. A good way is to save a reference when the object is created:

var prefab : GameObject;
private var spawnRef : GameObject;

function Start() {
    spawnRef = Instantiate(prefab);
}

In later code you can use spawnRef to reference the game object. But you can use any any number of other functions to find your prefab depending on the situation: GameObject.Find(), GameObject.FindWithTag(), Transform.Find(), etc. Note that Unity adds ‘clone’ to the name of a game object when it Instantiates it.