Game Object Hierachy

Just a quick question…

In this lecture, Empty Game Objects were created for the Player, Enemy, and Background. Each of these objects has its own transform (reset to zero). The appropriate 2D image was then dragged beneath the game object in the object hierarchy creating a child object with another transform and sprite renderer.

If you add a 2D sprite renderer directly to the parent object (by ‘add component’) and set that to the appropriate image you only have one transform and the sprite renderer component. Does this matter and is there a benefit to having an empty parent object with the image childed to the parent in its own object?

We usually have an empty main game object with the visual underneath it. This allows for several things; we could swap out the visual with another without any hassles. This is especially helpful in 3D where the models usually have an animation rig that consists of several more child objects. It also helps when the origin (or pivot) of the visual is not where we need it to be. In that case we can adjust the child object to where we want it to be and all translations, rotations and scaling we do on the parent will happen where we need it to be. If it’s just a static sprite, or some sprite that’s animated using a spritesheet, or the pivot is fine and there will be few to no changes to the visual you can certainly just add a sprite renderer on the main game object. I personally never do that but I just got into a habit of having an empty object with everything underneath it

1 Like

Thank you for that explanation.

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

Privacy & Terms