Confirm Instantiation or Object Confirm it's Instance


I kinda have an argument here. So I need to know, what would be better in a case of having different ways of spawning enemies and keeping these enemies in memories as integer variables.

Make each type of spawning confirm that an object has been correctly instantiated or make enemies simply confirm their existence when the awake?

Here a more thorough explanation, perhaps I wasn’t clear enough. I keep tabs on my instantiated objects with an Array : Int with each Int pointer representing a certain object. This enable me to keep in memory Objects across several scenes, using a very low memory footprint.

So what I’m actually asking is, keeping in mind there’s multiples scripts that can instantiate these objects. Is it better to have each scripts confirm the existence of the object they spawned which get me to simply copy the same code across several scripts or simply have a script attached to my objects that let them confirm their existence?

The instantiated objects won’t be integer variables, they will be of type GameObject. If you just want to confirm that they instantiated OK, check the return value from your instantiate call. If it is null, then something went wrong.

In any case if you need to reference them later you’ll need do this anyway so you can add the returned object to an array etc.

You can do this:

var instance : GameObject;

instance = Instantiate(Prefab, Position, Rotation);

You could also Add each one to an array as you create them.