Instantiating prefab as Transform?

Hello there!

Until today, I’ve been instantiating my objects using Instantiate(Resources.Load etc.), but then I stumbled across a tutorial where the author uses prefab linking through the Inspector.
My question is:
I don’t understand why he instantiated a Transform instead of a gameObject on his script, still what is being generated in the game is the full game object?
Bear in mind, the shotPrefab is an object which contains a sprite, a box collider, a script etc.
Why an instantiation of it’s Transform would generate the whole gameObject in game? :face_with_spiral_eyes:
Here’s the code:

//Creating the prefab variable

public Transform shotPrefab;

//Later on the code, instantiating it

var shotTransform = Instantiate(shotPrefab) as Transform;

//Treating it as just a Transform

shotTransform.position = transform.position;

Thanks in advance! :slight_smile:

EDIT:
Found the answer to my question here:

You can instantiate as Transform if you’re going to be mostly referring to the Transform component. It’s more convenient, and slightly faster.

–Eric

You can’t have a Transform component, or any component, without a GameObject. (Also you can’t have a GameObject without a Transform component, but that’s a special case.)

–Eric