Some complex objects may need to be separated in sub-objects, each one with its own components. Those sub-objects need to be somehow attached to the main object and work together to create the necessary object behavior.
In this section, we will cover the following concepts related to components:
- Parenting of objects
- Possible uses
Parenting of objects
Parenting consists of making an object the child of another, meaning that those objects will be related to each other. One type of relationship that happens is a Transform relationship, meaning that a child object will be affected by the parent's Transform. In simple terms, the child object will follow the parent, as if it is attached to it. In an example, imagine a player with a hat on their head. The hat can be a child of the player's head, making the hat follow the head while they are attached.
In order to try this, let's create a capsule that represents an enemy and a cube...