Transform instead of GameObject

Curious… why use a Transform instead of a GameObject for the Instantiate at Runtime reference?

Interesting question to which I’m going to offer an assumption from looking at https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

It looks like it doesn’t matter what part of the prefab or GameObject you use to Instantiate. However it is most likely that after instantiation you would want the Transform in order to position and rotate your object.

In the example, they use the Rigidbody and the function returns the new instance of the Rigidbody

// Instantiate the projectile at the position and rotation of this transform
Rigidbody clone = Instantiate(projectile, transform.position, transform.rotation);
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms