Making the instantiated explosion a child of 'SpawnAtRuntime' GameObject

Hi again,

When assigning the enemy death explosion GameObject as a child of the ‘SpawnAtRuntime’ Gameobject through code, why do we have to do it like this: ‘explosion.transform.parent = parentGameObject.transform;’ ? I don’t understand why we have to use the ‘transform’. Why can’t we just do it like this: ‘explosion.parent = parentGameObject’ ?

We aren’t assigning the transform of the explosion GameObject as a child of SpawnAtRuntime, we are assinging the whole GameObject. So why the transform?

Thank you.

Hi @Knife_Juggler,

The parent property is part of the Transform object. See the API.

Is this what you wanted to know?


See also:

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

Privacy & Terms