Creating Your First 32d Game - Lesson 1 - Student Guide - v01
Creating Your First 32d Game - Lesson 1 - Student Guide - v01
3D game: Learn
collision detection
in Unreal Engine
Student guide
Activity 1 | Build Your First 3D Game: Learn Collision Detection in Unreal Engine
Overview
Unreal Engine is an immersive 3D game engine that powers
some of the most popular video games in the world. While
some games require teams of professionals to produce
a final product, you can get started with no experience.
Rather than focusing solely on basic concepts of computer
programming, you’ll jump straight into building a video game.
This series of activities is designed to guide you through the
process of creating a 3D video game while highlighting the
important computing concepts along the way. We hope the
promise and excitement of building a video game will give
you the context and motivation to learn essential computer
programming concepts.
fig 1
fig 2
fig 3
Locate the Content Drawer. This can be found at the bottom of the
screen. By clicking on the button indicated by the arrow, you can
show the sources to make navigation through the folders
much easier.
fig 4
fig 5
Actors
The term "Actors" is used to identify the various objects or elements that are in a Level.
While the phrase is commonly used to identify people in films and TV, it is also a term used
to refer to different types of objects in a level seen in the viewpoint.
Do not forget to hold down the RMB while using the following
keyboard keys:
• W forward
• S backward
• A left
• D right
• E up
• Q down
You can also press the F key to frame any selected asset or actor.
Select an asset in the viewport, then press the F key and see what
happens. Select another asset and press the F key again.
Next, open the Levels panel. This can be displayed by navigating to Windows > Levels.
Click and drag the window by the tab to dock it next to the World Outliner so we can use
it later.
fig 8
fig 9
fig 10
fig 11
fig 12
Move your mouse over the Viewport and click the left mouse button. This will give you control
of the player. You can use the mouse to look around, and use the following buttons to move;
W = move forward
A = move left
S = move right
D = move backward
Space = jump
Hold Shift while moving = sprint
Try walking onto the circular platform over the pit. What happened?
Press the Esc key on the keyboard to leave the game and return to edit mode.
fig 13
Collison Detection
As you may have experienced in this test, just because an object appears to be solid doesn't
mean that it will behave that way. In the physical world, it's easy to predict and observe two
objects colliding. When dealing with colliisions in a simulated environment, the attributes
of objects need to be defined along with their positions. Math formulas in the code will
calculate if two objects are overlapping, thereby causing a collision. When the collision is
detected, it will perform a specific action assigned by the programmer. In our first example,
the collision doesn't exist, so the player couldn't stand on the platform. To correct this, we
will need to define a collision area around the platform so we can have the player stand on
the platform.
Some fantastic mathematical formulas are capable of calculating collisions. Without them,
the games would be pretty boring. Thank you, math!
If you need to deselect an Actor, hold Ctrl and click the Actor. Or press the ESC key to
deselect all selected Actors.
NOTE: You can also open the Static Mesh Editor by navigating through the Content Drawer:
Content > Hour_of _Code> Static_Meshes and double-click on the SM_Platform_M asset.
fig 14
fig 15
fig 17
If you look at the platform you will also see the collision
you have created. Can you spot the other collision
volumes for all the other Actors within the level?
Hit-Box
Have you heard of the term "hit-box" in video games? In a fighting game for example, the
hit-box is the defined area where the payer will take damage when hit. It's also possible that
a hit to the head can cause more damage than a hit to the arm. This is all done with collision
volumes such as the ones we are working on in this project.
Look at the player example in the image above. Can you see the collision volume shape that
surround the body? Notice how the collision volume doesn't match the shape of the body
exactly. lf you've ever been hit by a projectile that "technically" missed your player, this is
the reason.
The basic reason for a simplified collision volume is because of compute resources. A more
exact shape would increase the computing power which would slow the responsiveness of
your game. Therefore, as a Game Developer, you would have to balance precision against
the most dreaded foe of all ... lag!
fig 18
fig 19
Showstopper Bugs
When the player falls into the
pit, they are stuck and can’t get
out. This can be called a bug
because the game can’t go on.
or…
Play the game again and check that your character resets when they jump into the pit. You
might need to move the Pain Causing Volume around a little bit to get it to work the way
you want.
fig 22
fig 23
fig 25
fig 26
fig 27
fig 28