0% found this document useful (0 votes)
37 views26 pages

1.2 Basic Game Object Manipulation and Transformations

The document discusses game objects in Unity and basic transformations of game objects. It defines game objects as the fundamental components in Unity that represent characters, props, and scenery. It also covers parenting relationships between game objects and how moving, rotating, or scaling a parent game object affects its child objects. The document provides instructions for a practice on manipulating the transform of a game object in a 2D Unity project.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views26 pages

1.2 Basic Game Object Manipulation and Transformations

The document discusses game objects in Unity and basic transformations of game objects. It defines game objects as the fundamental components in Unity that represent characters, props, and scenery. It also covers parenting relationships between game objects and how moving, rotating, or scaling a parent game object affects its child objects. The document provides instructions for a practice on manipulating the transform of a game object in a 2D Unity project.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Basic Game Object

Manipulation and Transformations


Objectives


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.

A child GameObject moves, rotates, and scales exactly as its


parent does. Child GameObjects can also have child
GameObjects of their own. A GameObject can have multiple child
GameObjects, but only one parent GameObject.

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.

Proficiency in navigating the scene window is crucial when


working on a game project. Necessary components such
as tiles, sprites, game objects, etc., have already been
created; students only need to download and import them
into the project.

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 14


Practice – GameObject

Create a new Unity 2D project.

Download the asset files. Drag and drop all folders to the Asset folder of the Unity 2D project.

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 15


Practice – GameObject

Create new Scene.

In the Project window, navigate to Assets > Prefabs > 1.2_Basic-
Game-Object. Drag and drop ./Assets/Prefabs/Tilemap Grid.prefab
into the Hierarchy window or the Scene window.


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.

3. In component Tilemap Renderer - Additional Settings, set ‘Sorting Layer’ to ‘Background’.

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.

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 19


Practice – Sprites, Tilemap (Optional)
A. Practice with Slicing
Sprite
1. Select all sprite assets set:

Pixel per Units: 32 and apply.

2. Select SPA_Rock_Grass_Water asset, set:


Sprite mode: Multiples and apply.

3. Select SPA_Rock_Grass_Water asset, click


Spirte Editor and set:
Slice type: Automatic and apply.

Repeat steps 2 and 3 for ‘SPA_Background brown tint’

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 20


Practice – Sprites, Tilemap
A. Practice with Slicing
Sprite
Slice SPA_Player_Ginger
1. Select SPA_Player_Ginger asset, set:

Sprite mode: Multiples and apply.

2. click Spirte Editor and set:



Slice type: Grid By Cell Size

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’

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 21


Practice – Sprites, Tilemap
A. Practice with Slicing
Sprite
Slice SPA_Player_Ginger
1. Select SPA_Player_Ginger asset, set:

Sprite mode: Multiples and apply.

2. click Spirte Editor and set:



Slice type: Grid By Cell Size

3. Set params:

Pixel size: X: 32; Y: 32

Offset: X: 10; Y: 4

Padding: X:6; Y: 6

Click Slice and Apply

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 22


Practice – Sprites, Tilemap
B. Create
Tilemap
1. Drag and drop ‘Tiles’ folder to Asset folder of
Unity 2D project

2. Select GameObject > 2D Object > TileMap >


Rectangular. Rename to ‘Platforms Tilemap’

3. Open Tile Palette by select Window > 2D > Tile


Palette.

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 23


Practice – Sprites, Tilemap
B. Create
Tilemap
Because we imported the ‘Tiles’ folder. 'Platforms Tilemap' will already be present in the tile
palette.

Select the edit mode and use the Tile Palette toolbar to draw tiles onto the scene.

Rick Davidson, Complete C# Unity Game Developer 2D, 2023 24


Conclusions


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

8: Unity Technologies, Unity Manual, 2023

26

You might also like