To getComponent() or Instantiate ?

Ok I have been writing some scripts and they all interlink calling variables from each. The thing is that I never user getComponent(). I just instantiated the class (public Class1 class1;).

Is the code more efficient if I use getComponent instead of instantiating?
If i’m just calling a variable should I just use getComponent?

You ARE kinda confused with this…

Both getComponent and Insantiate are used in VERY different scenarios.

When you are Instatiating an object, it means create an object “such as a projectile or any gameObject” usually, a prefab.

getComponent - means using the variable OR calculated value from ANOTHER script, to import the data for use in the script you are using.

This certainly means that both Instantiate AND getComponent are used in VERY different senses and NOT to be confused with each other

Hoping you understand…


Good morning @Ryzokuken.

Excuse my English.

In my case I was assembling several objects that had systems of particles, in the explosion of barrels grouped.

That was expensive so I did a pull of several of these objects but in order to handle the particle systems (play and stop) I have to do a GetComponent of each of these objects. So I do a “play” and “stop” every time I need to use them again with a new group of barrels.

The question would be how much more or less expensive is my routine now?

thanks for your time.