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?
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!
EDIT:
Found the answer to my question here: