General Questions about parenting game objects

This is more of a philosophical question than a technical one…

What’s the point in making a hierarchy of objects? For eg. making one object a child of another.

In what cases would it be good practice to you use this technique?

Your help is greatly appreciated. Thanks!

Parenting objects is useful for different stuffs. An easy one is making prefabs.

Most of the time you also need an object to be depend of an other one. Like if you want an object to stay in the hand of a character, it will be a child of the hand. So I don’t need to do anything. If I move my hand, the object will follow it.

It is also really useful in UI. each child depend on the parents. If you want to make a grid or any different layout. As children depend on the parent, if you resize the parent, the children will respond corresponding to the settings you will put without any extra code.

There are many many ways to use hierarchy but I think this is a good overview :slight_smile:


Another example is moving group of objects. Say I have a character which consist of n sprites, if i do not group them in a gameobject, it is difficult to move them together. Try to think how difficult it is to implement a script to move those n objects, and how easy to move a single parent of these objects.

This also apply to some cases when you would like to instantiate weapons or equipments on the character, which would “moved” by the character’s own animation. Say, the character is holding a sword, and his hand is moving slightly in idle animation. How can you do these effects if you don’t put the weapon in the hand objects of the character as a child??

There are still many other examples, but for me the basic usage of the hierarchy is for grouping purpose, which allows me to manage them in a much easier way.