- Unity - Using the Asset Store
- Unity - The Particle System
- Unity - Materials and Shaders
- Unity - The Slider
- Unity - Text Element
- Unity - The Button
- Unity - Starting with UI
- Unity - Introduction to Audio
- Unity - The Console
- Unity - Coroutines
- Unity - GameObject Destruction
- Understanding Prefabs and Instantiation
- Unity - Custom Collision Boundaries
- Unity - Rigidbodies and Physics
- Unity - Understanding Collisions
- Unity - Basic Movement Scripting
- Unity - Saving and Loading Scenes
- Unity - Internal Assets
- Transforms and Object Parenting
- Unity - Modifying Sprites
- Unity - Creating Sprites
- Unity - Installation and Setting Up
- Unity - Introduction
- Unity - Home
Unity Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Unity - Transforms and Object Parenting
When we just got started, we discussed how a gameObject’s transform is arguably its most important component. Let us discuss the component in detail in this chapter. Additionally, we will also learn about the concept of Object Parenting.
Transforms have three visible properties − the position, the rotation, and the scale. Each of these have three values for the three axes. 2D games usually do not focus on the Z-axis when it comes to positioning. The most common use of the Z-axis in 2D games is in the creation of parallax.
The rotation properties define the amount of rotation (in degrees) an object is rotated about that axis with respect to the game world or the parent object.
The scale of an object defines how large it is when compared to its original or native size. For example, let us take a square of dimensions 2x2. If this square is scaled against the X-axis by 3 and the Y-axis by 2, we will have a square of size 6x4.
In our subsequent section, we will discuss what Object Parenting is.
What is Object Parenting?
In Unity, objects follow a Hierarchy system. Using this 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.
For example, an object with no parent placed at (10, 0, and 0) will be at a distance of 10 units from the game world’s centre.
However, a gameObject with a parent placed at (10, 0, 0) will consider the parent’s current position to be the centre.
GameObjects can be parented simply by dragging and dropping them onto the desired parent. A “child” object is depicted in the object pst with a small indentation along with an arrow next to the parent object.
Parenting GameObjects has a number of uses. For example, all the different parts of a tank could be seperate GameObjects, parented under a single GameObject named “tank”. That way, when this “tank” parent GameObject moves, all the parts move along with it because their positioning is updated constantly according to their parent.
In our subsequent lesson, we will discuss the internal assets. We will also learn how to create and manage the assets in our project.
Advertisements