Javatpoint Logo
Javatpoint Logo

Transforms and Object Parenting

In Unity, the Transform component has three visible properties - the position, rotation, and scale. Each of these properties has three values for the three axes. Means, Transform is used to determine the Position, Rotation, and Scale of each object in the scene. Every GameObject has a Transform.

Transforms and Object Parenting

Properties

Position: This is the position of the transform in X, Y, and Z coordinates. 2D games generally do not focus on the Z-axis when it comes to positioning. The most frequent use of the Z-axis in 2D games is in the creation of parallax.

Rotation: This property defines the amount of rotation (measured in degree) an object is rotated about that axis with respect to the game world or the parent object.

Scale: The scale of the object defines how large it is when compared to its original or native size. For example, let us take a square of 2x2 dimensions. If the square is scaled against the X-axis by 3 and the Y-axis by 2 we will get a square of size 6x4.

These properties are measured relative to the transform's parent. If the transform has no parent, the properties are calculated in world space.

Object Parenting

In Unity, GameObjects follow a Hierarchy system. Using this hierarchy system, GameObjects can become parents of other GameObjects. When a GameObject has a parent, it will perform all its transform changes with respect to another GameObject instead of the game world.

A parent object causes all children objects to move and rotate the same way the parent object does, although moving children objects does not have any effect on the parent. Children themselves can be parents; e.g., your hand is the child of your arm, and fingers are children of your hand.

Parenting GameObjects has a number of uses. For example, all the different parts of a tank could be separate GameObjects, parented under a single GameObject named "tank." Hence, when this "tank" parent GameObject moves, all the parts move along with it because their positioning is updated constantly according to their parent.

Transforms and Object Parenting
Next TopicInternal Assets




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA