Unity Tips and Tricks: Set New Parent for GameObject in Scene Unity

https://docs.unity3d.com/ScriptReference/Transform.SetParent.html

This guide allows you to better manage Game Objects. For example, in our project, we had a need to instantiate objects from a Sub Component of a game object and do not attached to a player object.

In our project, for example, instantiating projectiles was creating some undesired behavior and parenting the projectile to the character themselves.

This was actually creating some fun “around the world” behavior by flipping x position to negative x when the character turns around.

The solution to this problem was to create a blank Game Object component in the scene named “ProjectileParentObject.”

The only purpose of the “ProjectileParentObject” is to be a blank Game Object (with static physics) that contains projectiles in the world of the Game.

Leave a Reply

Your email address will not be published. Required fields are marked *