1.2 Basic Game Object Manipulation and Transformations
1.2 Basic Game Object Manipulation and Transformations
Understand the concept of game objects and their role in Unity.
Learn basic game object manipulation techniques.
Grasp the fundamentals of transforming game objects in Unity.
2
What are Game Objects?
GameObjects are the foundational components of a Unity game project.
“GameObjects are the fundamental objects in Unity that represent characters, props and scenery. They
do not accomplish much in themselves but they act as containers for Components, which implement the
functionality.”[8]
Every object in your game is a GameObject, from characters and collectible items to lights, cameras and
special effects.
2: Buttfield-Addison Paris, Manning Jon, Nugent Tim, Unity game development cookbook: essentials for every game, 2019
8: Unity Technologies, Unity Manual, 2023
3
Hierarchy Panel - GameObjects - Nested
A parent GameObject has other GameObjects connected to it that
take on its Transform properties.
A child GameObject is connected to another GameObject, and
takes on that GameObject’s Transform properties.
4
Transforms
“The Transform stores a GameObject’s Position, Rotation, Scale and parenting state. A GameObject
always has a Transform component attached: you can’t remove a Transform or create a GameObject
without a Transform component.”[8]
1: Hocking, Joseph; Schell, Jesse, Unity in action: multiplatform game development in C#, 2022
3: Geig, Mike, Sams teach yourself Unity Game development in 24 hours, 2014
5
Transform Tool
You can use the Transform tools on any GameObject in a scene.
When you select a GameObject, the tool Gizmo appears within it. The appearance of the Gizmo depends on
which tool you select.
6
Scene View – Position GameObjects
RectTransform (T)
The RectTransform is commonly used for positioning 2D elements such as Sprites or UI elements, but it can
also be useful for manipulating 3D GameObjects. It combines moving, scaling and rotation into a single Gizmo.
Transform (Y)
The Transform tool combines the Move, Rotate and Scale tools. Its Gizmo provides handles for movement and
rotation. When the Tool Handle Rotation is set to Local (see below), the Transform tool also provides handles for
scaling the selected GameObject.
7
Transforms - Understanding 3D coordinate space
1: Hocking, Joseph; Schell, Jesse, Unity in action: multiplatform game development in C#, 2022 8
Transforms - Understanding 3D coordinate space
Left-handed vs. right-handed coordinates
The positive and negative direction of each axis is arbitrary,
and the coordinates still work no matter in which direction the
axes point. You simply need to maintain consistency within a
given 3D graphics tool (animation tool, game development
tool, and so forth).
But in almost all cases, x goes to the right and y goes up;
what differs between different tools is whether z goes into or
comes out of the page. These two directions are referred to as
The z-axis points in a different direction on the left hand versus the right hand.
left-handed or right-handed; as this figure shows, if you point
your thumb along the x-axis and your index finger along the y-
axis, then your middle finger points along the z-axis.
1: Hocking, Joseph; Schell, Jesse, Unity in action: multiplatform game development in C#, 2022 9
Transforms - Understanding 3D coordinate space
Unity uses a left-handed coordinate system, as do many
3D art applications.
Many other tools use right-handed coordinate systems (ex:
OpenGL), so don’t get confused if you ever see different
coordinate directions.
1: Hocking, Joseph; Schell, Jesse, Unity in action: multiplatform game development in C#, 2022 10
Transform Component in Inspector
1: Hocking, Joseph; Schell, Jesse, Unity in action: multiplatform game development in C#, 2022 11
Understanding local vs. world coordinate space
Every game object in Unity has a position, but a position needs a reference frame. In particular,
Unity offers two ways to see (and set) coordinates:
World coordinates: These are absolute coordinates of where the game object is located (by
absolute, I mean with respect to the world frame, which is considered to be absolute in the game)
Local coordinates: These are the coordinates of where the game object is with respect to its
parent
12
Parenting and Child Relationships
“Game objects can be the child of other game objects. When a game object moves, rotates, or scales, its children
are affected as well. This means that you can create hierarchies of game objects that work together as a system; for
example, a car could have each of its four wheels as child objects, which means that they automatically stay in the
correct position as the car moves around.”[2]
TIPs: Before linking any child objects to it, make sure to reset the Trans- form options (Position and Rotation to 0, 0, 0
and Scale to 1, 1, 1) of the empty root object to avoid any oddities in the position of child objects.
2: Buttfield-Addison Paris, Manning Jon, Nugent Tim, Unity game development cookbook: essentials for every game, 2019 13
Practice
In order to understand the moving of GameObject’s transform, use Unity 2D for this practice to create a scene
and Player GameObject.
The exercise will take 20 minutes, and students need to familiarize themselves with operations in the scene
windows, using tools such as move, rotate, scale, zoom in, and zoom out.
Note: Remember to select "Reset Transform" each time you add a
GameObject to the Scene.
16
Practice – GameObject
Unity 2D layer setting
1. Select ‘Background Tilemap’, on inspector window, click Layer > Add Layer.
2. In the sorting layer section, click the '+' button and add 3 layers: Background, Platform, Player.
Arrange them in the order of their intended display.
17
Practice – GameObject
1. Perform the aforementioned step 3 for the remaining GameObjects within the 'Tilemap Grid' with the
Sorting Layer set to Platforms.
2. Add the 'Exit' GameObject to the scene, adjust its Transform if necessary, and set the Sorting Layer to
Platform.
3. Add the 'Ginger (Player)' GameObject to the scene, adjust its Transform if needed, and set the Sorting
Layer to Player.
4. Finally, delete the default Main Camera in the scene and add 'Cameras' by dragging and dropping it
from the Prefabs folder.
18
Practice – GameObject
Press Play button (Ctrl + P) to test the new scene.
3. Set params:
Pixel size: X: 32; Y: 32
Offset: X: 0; Y: 0
Padding: X:6; Y: 6
Click Slice and Apply
Repeat steps 1,2 and 3 for ‘SPA_Background brown tint’
3. Set params:
Pixel size: X: 32; Y: 32
Offset: X: 10; Y: 4
Padding: X:6; Y: 6
Click Slice and Apply
Select the edit mode and use the Tile Palette toolbar to draw tiles onto the scene.
Explored game object fundamentals and their significance in Unity scenes.
Learned manipulation techniques—selecting, moving, rotating, and scaling objects.
Mastered Transform component usage and understood coordinate systems' impact.
Grasped parent-child relationships' influence on object transformations.
25
References
1: Hocking, Joseph; Schell, Jesse, Unity in action: multiplatform game development in C#, 2022
2: Buttfield-Addison Paris, Manning Jon, Nugent Tim, Unity game development cookbook: essentials for every
game, 2019
3: Geig, Mike, Sams teach yourself Unity Game development in 24 hours, 2014
26