Hello, this is Yeong-hoon Lee
Today we will create User Input Mapping and Player Actor
This chapter will create an environment using Blueprint
A project for creating a shooter game
And we will learn about the core of Unreal Engine
Which is Actor and its components
And we will also learn about how to
Move objects with user input
Creating Prototyping Environment
We will be creating a Blueprint-based shooter project
A shooter project is simple, it has the player
And then its enemies here
And we have some bullets
So these are the three characters
Or three Actors
And if the bullet hits the enemy, or the enemy hits the player
The latter will be destroyed; that's the simple mechanism
So today we will focus on this player
And we will start a new project
So we will be able to learn about the first things we need to do
When we make a new project
So let's start by creating a project
Run your Unreal
Let's make a Blank project
And Blueprint, include Starter Content
And let's name it a shooter
For Blueprint,
Let's say BP
BP_Shooting, let's do that
Create
Now we have a project
So the first thing is to create our Level
Open this Content Drawer, and we only have Starter Content
Let's create some folders here
Press Add here
Select New Folder, name it 'Maps'
We'll make some maps, and let's make a folder for Blueprint
You could do this or press Add
See, 'New Folder'
Or at Content Drawer, right click
And there's also 'New Folder', the menu is the same
Click, 'Blueprints'
That's the folder name we have
And let's make a map to process it
This map here isn't the one saved
It's the default map we get when we first run it
We won't be using this
At File, we have New Level, click on it
And we have four maps
Notice how each pair has the same theme
The right two are the basic ones
The maps that we use a lot for a standalone format
And the left two have the concept called 'World Partition'
Which processes multiple levels of a map, which is a complicated job
So this Level helps with such things
Here, we will go with the basic, simple Level
It's a shooter, so the Level will be empty
Let's start at this Empty Level
Create, and this Level has nothing
Let's first save
Ctrl S will save the proejct
Let's save it under 'Maps' folder
Here, it says 'NewMap' but let's say 'GameMap'
'GameMap', and now save
And at Content Drawer, we have our 'GameMap' here
Also at the top on this tab it says 'GameMap'
At Outliner too, 'GameMap'
So when you're checking for what this map you have is
You can check for its name at this tab or at this Outliner
And, when we first run this map
It should be this map that opens
So we will do some work on this Level
But we need to do something else before that
At an Unreal Level
It has to have its own Game Mode
So you first create Game Mode and add its player
And add all the settings before we process with it
So let's create a Game Mode
Let's make it under 'Blueprints' folder
Blueprints, right click on it and we have this
'Blueprint Class', let's create this
And we have 'Game Mode Base' here
So this will be the parent
Let's create an Actor, whose parent is this 'Game Mode Base'
Click on this
And it looks like this
This is Gam eMode, so 'BP_'... It's Game Mode of GameMap
Game, let's just say 'GameMode'
'BP_GameModeBase' is the name
Let's save here
And we will place it on this Level
Here, go to Edit
And we have 'Project Settings'
Click on 'Project Settings' and we get this window
And this must be the default setting you have
This is how it looks like
And with this, you may confuse the upper tab of
This window as over here
But this is the original form, and there's a separate one here
Let's bring it up here like this
So that they belong to the same tab group
So here, at Project Settings
Among many things, let's go with
'Maps & Modes'
So click on 'Maps & Modes'
And at the top we have 'Default Modes'
This is where GameMode goes in
And here, GameModeBase is placed in here as well
Click on this and, see our GameMode that we created?
Let's replace it with this
This will be the default Game Mode for all Levels
Meaning, we have a Level we just created
This map is called a Level
And if we make another Level
This Level will also have
This Game Mode as its default setting
But as we work through, we may need
Separate Game Mode for each Level
And what do we do for that?
First, open this Level
Double click to open the Level
And to the right, we have 'Settings'
Click on 'Settings' and we have 'World Settings'
Let's click on that
And next to Details, we now have this window, 'World Settings'
And here, we have 'GameMode Override'
And it says 'None' here
Meaning, the Default Game Mode that we set at Project Settings
That will be the Game Mode for this Level
And if we click this to change it
The Game Mode for this Level will be this
That's what it means
So when you work on your project
If you want to make many Game Modes to set to each of the Levels
Don't do each of it at Project Settings
Instead, at World Settings of each Level
You can place each to its right pair like this
So for me, I will set it at World Setting like this
The one at Project Settings is no longer needed
So we can change it back
Because we do not use it
And to see its settings, open 'Selected GameMode'
And we see the content here
It has Default Pawn Class
Also HUD, for Head-Up Display
HUD, and Player Controller
Game State, Player State, and many more
This is obviously at World Settings as well
Here, at World Settings, it also has Selected GameMode
Open it up, and this is it
And we can change each like so
Of course, the default Game Mode, GameModeBase, is a read-only one
Which we cannot edit
But if it's our custom Game Mode, we can change its parts
So let's do that
And now we need our player character
Let's create that, after we save it
And at Blueprints here
Right click to make another Blueprint Class
Here, we will use not an Actor but this thing called a Pawn
Let me briefly explain what it is
So this is the concept here
So, an Actor Class
It's the minimum of classes that can be born at a Level
So this class can be placed in the World
And something that inherits this Actor Class at World
This class is called Pawn
Starting with Pawn, the class can receive input from the user
While Actor does not allow inputs from the user
Of course, we can process it so that it can somehow receive it
But in basic terms, an Actor is something that does not receive any inputs
Only classes starting with Pawn can receive them
Of course, if we have two or three Pawn Classes
It's not that all of them gets the input
For an Unreal user
When the user processes an input
There's Player Controller
Which has the concept of possession
And it can control starting with the Pawn that it has Possessed
That's what can get the input
So even with many different Pawns
Or even a character that inherits a Pawn
So Actor, Pawn and Character are the
Three representative Classes at Unreal
For an Actor Class, they are the placed-things
And for Pawn and Character
It's like a chess piece that one can hold and move around
That's what they are
So we'll make our player a Pawn Class
What's different between Pawn and Character?
Pawn does not have a particular shape
It could be a car, or a plane
Or a carriage, something like that
If I want a puppy as my Pawn
Then we need to use a Pawn
But for humans, with two legs
If we want a player that is a human
We can choose the Character Class
So in this example, we're using a shooter
So for shooter, we will create our player using Pawn Class
Later, we will be working on TPS
And we will be able to work with the Character Class then
For today, let's try Pawn
So this is the gist of them
Here it says that Pawn Class can use Static Mesh
It's based on the default settings
We could use Skeletal Mesh here as well
So for the player character, they can do all the human things
Such as to jump, to swim
Of course, it doesn't just automatically work
You need some extra work to make it happen
But anyways, there are such components that are provided based on them
Which allow for such things
Going back
Let's create a player that inherits a Pawn Class
For this, shall we call it 'BP_Player'?
So let's check for World Settings
See BP_Player here?
You could switch it here
Or you can double click on our Game Mode Base to open it
And here at Details we have the content as well
Here, we have the player: Default Pawn Class
You can switch it to out BP_Player and compile
And when you come back here, this part will be changed
You can change it here to change it there
And change it there to change it here, it's the same thing
Let's assign it like so
I will use my preferred layout
I'll go with the Classic Layout
Sometimes, when you open a Blueprint Class
It may look like this, without showing everything
Here, just go to the top where it says 'Open Full Blueprint Editor'
Click this to bring back that familiar view
That's how it works
I will chek for Always here so that it compiles and then automatically saves
That's it
And now, I want to see this map right away when I open my Unreal
Until now, it has not been set that way
We only placed this at this Level
For this, go to Edit, Project Settings
Here, we have Maps & Modes
We used to deal with the Game Mode on the top
But right below that category, we have Default Maps
So here, 'Editor Startup Map'
Let's place our own GameMap we just created
Now, when we open our Unreal Engine
This map will be loaded right away
It's thanks to this Default Startup Map
Now we also have Game Default Map, which is
Something we created at Unreal is not limited to open at Editor
We can build it to create an executable (exe) file
Which we can publish later
And this means the map that first opens in that exe file
So we can set our GameMap here as well
So when we build it in an exe file, it will also open our GameMap
That's what it means
So with this setting
We can run it now
It has nothing for now, but over here at Outliner
BP_Player, and 0 means that we have one of it created
Meaning, we have one BP_Player being created automatically
Of course, we will need to relocate it and all
That's the basic setting we can have
Whenever we start working on an Unreal project
These are the things you need to do first
So create a project, and create the basic Level
And create a Game Mode Base for that Level
And create a player and set it there
And, since we are working on a shooter example
We need something here, right?
At this Level, we do not see anything for now
And this is just like the
The actual filming location
You know, filming for a movie or a TV series
You can consider this as the location for such
Imagine that location has no source of light; of course it's all dark
So what we need here is some light
And with that light we will be able to see
We also have a director who will be filming things with their camera
Only through which the video result we watch is created
Just like that, at Unreal Editor, we can start working on our project like so
So let's first add some light source
Here, we see Light on this third menu
We have things like Directional Light, Point Light, and Spot Light
Rect LIght as well
We have some multiple kinds, which are
To simplify, this is a direct lighting
And by that, we usually mean the sun
So this is like the sun
Point Light is literally like the lightbulb
See the icon here?
So it's like a lamp or a lightbulb
Which lights up around that source
Spot Light has a direction, in a cone shape
In terms of real life, it's like car headlights
Or flashlight-like light sources
And Rect Light is some source of light
From any display, such as television
And Sky is, obviously, the light from the sky
Since we are going for a 2D-style shooter
We only need this one Directional Light
Let's use this Directional Light
And we can set the location a bit
In fact, in our project, the location of light does not really matter
For sunlight, what matters more is in which direction it is pointing at
So this rotation is what matters more
So you can basically go with its default values
Let's set it up here
And now, we need a camera
See here, Cinematic
Or should we just search for a camera?
Let's look for the cameras
Camera, we have Camera Actor
Let's place it here
The camera looks like this
And the direction is, I think this way is better
To our bottom left, we have Gizmo
Place it so that the direction of X at Gizmo is towards the inside of the screen
So this is the optimal place here
So the camera goes here
Notice how this is a little tricky to place it
For this, let's go to this Details
And at Camera Actors
At Details, go to Transform, Location
Let's place everything at 0, 0, and 0
And let's push it back a little
We're pushing this a bit
So I moved it by around 1000
The measurement here is cm
So 1000cm is around 10m
Because 100cm is a meter
So that's where it goes
From the side, this is how it looks like
Moving Player
Let's now go to the place where our player will be born
We haven't worked on our player yet
Shall we place a cube here?
Let's place a cube at this origin point
Which is here
Let's run it and we see this
Notice how it doesn't look right, even with the camera being placed here
The camera shoudl look liek this, but here, we see the preview screen here
It should look like this, but it does not
This is because, even for cameras
It's only meaningful when this player uses that camera
Meaning, there can be more than one Camera Actors in place
There could be multiple
So what matters then is which camera that player is using
So click on this camera here
And at Details, we have this
Under Camera Settings, we have Projection Mode
At Projection Mode, we have Perspective
Which allows for persepctive
And this Orthographic, 2D
Orthographic projection, perspective projection
Projection means how we display it
And orthographic and perspective projection are a bit different
So for these
Let's talk about orthographic and perspective projection
In simple terms, they are
Perspective projection has the camera looking this way
And we have a screen like this
And this becomes a triangular pyramid
Which is here, it looks like this at the back
And what has filmed inside this space is
Condensed into this screen, that's what it is
Meaning, it brings in that perspective of what's closer and further away
This shape here is called a frustum
A rectangular pyramid should look like this
Like so, and like this, right?
Right? And here, this top part has been cut off like so
And this is called a view frustum
And that's for perspective projection
And now for orthographic projection
In simple terms, its final product looks like this
And it just simply films this
Like so
So whether it is closer or further away
Its size will look the same
Since we are creating a 2D work
Let's change this to Orthographic
And now this looks much bigger
Here Ortho Width is set to 512
Let's double this value
So doubling it is 1024, let's actually make it 1920
Let's make it smaller like this
And bringing it down
This part is very important, at Auto Player Activation
It is Disabled now
This means whether the player will automatically activate this for use
Open this, set to Player 0
Player 0 is called Local Player
You will be learning about multiplay at network
Network has the concept of my computer, the server
And someone else's computer
So the player that I am in control in my computer
That's a Local Player
So Local Player is like this Player 0
So Player 0 means me
The player that I'm controlling
So Player 0 is the one that is automatically activated in the beginning
That's the placement we want for our camera
Now run this, and notice how it's in the center here
That was on setting the camera
That was a simple process
And then, since this is a cube
We can now make our player do the same thing
Save, and go to our BP_Player
For our player, we have Components here; click on Add
Here we have Cube
Place it like this
It looks like this, and save
And run
And place this at 0, 0, 0 to see this
But its initial location is not 0, 0, 0, right?
So we need to set this up as well
Here, we have Player Start
This means, when the player is initially created through Game Mode Base
This is the location for that player
So let's bring out Player Start Vector
Place it at 0, 0, 0, and run it
Now we see it on our screen
Let's now move it around
First we need to learn about the input process
Here, on the top, let's go back to Project Setting
And here, let's scroll down
We have Input here
Click on Input and see this
We have Bindings
At Bindings, we have two concepts
See these two plus signs
We have Action and Axis
Axis is for the mapping
So we can add things like vertical and horizontal axis
And Action is literally the action
For example, we can say
For example, if pressing 'A' and 'D' on the keyboard moves the character
We could use Action for that
But basically, using Axis will be much more convenient
So press 'A' to move to the left, and 'D' to the right
And 'W' to north and 'S' to south, to realize this
We usually use Axis
I said left or right, but in fact it is
Vertical or horizontal; that's the input for the concept
And this Axis value, by multiplying it to the direction
We create that final direction
And we will be doing that here
Click on Axis Mapping to add this
Like so
So this is the horizontal axis, let's name it 'Horizontal'
And we can assign two buttons for that horizontal axis
We could click to find, which is a lot of work
So click on the button and assing 'A' and 'D'
Press 'A' and it will become 'A'
Press, 'D' and it will be 'D'
'D' for right and 'A' for left
The increasing axis value is a positive number, and the decreasing a negative
So for Scale, since 'A' is left, let's make it -1
This means, when we press D, the axis value for Horizontal becomes 1
If we don't press anything, it remains 0
And pressing 'A' it becomes -1
Now, let's make another axis
Let's make a 'Vertical' axis
So now we have Horizontal and Vertical
Same thing here
Let's se 'W' and 'S' here
'S' is the negative number, because that's what goes down
So let's assing it like so
After having created Horizontal and Vertical
Now we can move to BP_Player for some coding
I said Event Graph is where the coding happens, right?
So let's move to this window
Now, the control happens when the player actually moves
So it's not something done once when it is born
It is something that is has to continue to do so
So let's work on Tick
Let's work on it right here
Then shall we start working with Horizontal?
Search for Horizontal and we get two results
One as Events and another as Values
For these, let's try both
Event is something we've already looked at
It looks like this
So this has that Execute Pin
And next, for Values
Values is in a Pure status, see?
Remember that concept of Pure?
It's Pure, which is appropriate for our case
Since we are using it for our Tick, rather than getting the event
And saving it somewhere to use it again
It will be more convenient to bring in the value right away for use
So let's do this, and let's bring in Vertical as well
Let's choose Values
At Unreal, I once talked about the concept of axis
At Unreal, this is how the axis looks like
We have three, this being the right
This is Y, and this is front or X, and top or Z
This is how it looks like
So X, Y and Z are placed
The direction of the axis looks like this
And we can set the direction based on this
So now, let's create its direction
The data type for direction is Vector
So let's search for Make Vector
We have X, Y and Z
I said that horizontal is the Y axis, right?
So let's add that horizontal part to this Y
And vertical is Z
So Vertical goes to Z
Now we have that yellow Vector data type
To create that value
So we can move this direction
Here, we have a very important concept
In physics, we have equations of motion
Which will be used here
The equation for motion is P = P0 vt
P here is actually an L for location
But in Physics, P for position is more often used
While Unreal uses L for location
So it's the same thing but meaning Position
Position and Location are like same concepts
So based on the equation sign, the one on right is done first
And then moved over to the left
So these are the same P's, but this is the final location
Equals to the current location
Plus, V here is for velocity
V for velocity
Velocity
And the multiplication, which is omitted here
So multiplied by t
And t here is the Delta time
It's a Delta time caleld Delta Seconds
So this is the equation here
And to break down even more, velocity is direciton multiplied by speed
Multiplied by speed
Sometimes in Korean dictionaries
They use velocity and speed interchangeably
But here I am distinguishing the two
So velocity is a Vector
I haven't labelled them here, but these are all Vectors
All Vectors, except for the 't' here
This is a Vector
Velocity is a Vector too
Velocity meaning direction and speed
So shall we work on it first?
I will have more chance to explain things like Vector
Now let's move with this
Let's frst bring in the current location
Let me do this here first
P = P0 vt
So this here is the direction
This part is 'Direction'
And, though I haven't written it here
This here is the direction
Meaning, we now need one for speed
Let's create a variable
'Speed', the variable is a float type
Let's call it 'Speed'
Compile, and I want it to move 5m a second
500 is 5m
So let's add that
Let's now bring in our Speed
So adding these two is our Velocity
Direction multiplied by Speed
Let's multiply them, this and Velocity, that's how it works
So what is this again? this is for 'v'
T is, it is set to Delta Seconds here
We multiply this as well
So this and go for Multiply
Oh, we need to multiply this first
Let's do Vector first and then multiply Float like so
So this is the 'vt' part of the equation
Now we need the current location, or position
For that, we can add the current location of our Actor
So 'Get Actor Location'
This is our P0
So we add this and this
Adding the two will complete the equation
Let's add these using Add
I'm working in the order of the equation
Direction, and Speed
And Detal Time, the 't' part, multiplied
So this is our 'vt', these two multiplied together
And we have 'Get Actor Location', to add our P0
So we're combining these two, and finally we Set
Set Actor Location to add them
Now, the new Position is this
Now let's connect that Execute Pin
Now, shall we see it? Run
Press 'A', 'D', 'W', and 'S' to move it around
Now we can move the player around
But just as it is now, it doesn't look too right because
I don't know if you can tell, but the movement of pressing one key
And that of pressing two keys, such as 'W' and 'D', is different
The diagonal movement is a little faster
This is because, for this we need to understand more about Vector
Let me write it out here
If we press 'W', we have created a Vector that looks like this
Which has the size of 1
This is W, and this is A, let's call it our Vector A
And when we press 'D', we now get this Vector
Whose size is also 1
Let's call it 'B'
So when we press 'W' and 'D' at the same time
It adds these two
And adding two Vectors is usually a rectangular format
Meaning, this Vector below stays here
And this Vector here is added right here
Something like this
And a line connects to that point
This line doesn't look too straight
So we connect these points
Like this, and this becomes the C Vector
C=A B, it's all Vectors, like this
So A B becomes C Vector
But look at the size, this is bigger
Because, when we draw a circle
Let's say that there's a circle
Which is 1m in size
This circle does not look too perfect, but let's move on
So adding this looks like this
This is the Vector, which is longer by this much
Because it's 1 only up until here, right?
This is longer by this much
With that, if we are multiplying it by any Speed
Its size will get even bigger
This is what the Pythagorian theorm explains
Which is expressed by this
The square of C is equal to the square of A plus the square of B
Meaning, we can add a square root on each end like so
So here, A is 1, B is 1, and the square of 1 is 1
So this becomes the square root of 2, which is the square root of C squared
Then C is, this is C, square root of 2
Meaning, C is equal to square root of 2
So what is square root of 2? 1.4 something
Which is bigger than one
Much bigger, actually; that's why moving diagonally
Will make you move faster
So we need to now fix this
What we can do is, we can set Vector
To have its size as 1
We need to do this
Which is an easy task
This work is called Normalize
Normalizing the Vector
And we use the term normalize
To normalize
And we can normalize this as well
Let's move over here, and this is where it gets bigger
So we need to normalize this area here
Look for 'Normalize'
Let's add it like so
Compile and run
Now the diagonal movement has the same
Or at least not too different speed
I was moving a little fast and
I should go back to Vector and talk about it a little more
Let me summarize it again
So what is Vector again? Vector
A Vector has its direction and size
That is a Vector
For example, let's say we have this car
Which can run 200km an hour
So is that the Vector?
What is always paired with Vector is Scalar
Scalar is the physical quantity for a size
So is this Scalar or Vector?
Of course Scalar, since this has no direction
Or another example is
There's this wind, and this is East
It's an East wind, 3m an hour, a very strong wind
So is this East wind a Vector?
Yes, this is Vector
Because we have that direciton, East, as well as its size
So this is Vector
And Vector has a characteristic where
It's the same Vector if it has the same size and direction
Or, to be precise
Let's say we have a Vector that looks like this
So this Vector 'A' and 'B' are the same Vectors
The same Vectors
With the same direction and size, they are the same Vectors
This may be an abstract concept for now, but that's how it works
So we tried using some physics equations
To move our object around
Let's summarize the chapter
Initiating Prototyping Environment
Creating Shooter Project Create Level, Save with the name 'MainMap', go to Project Settings, Maps & Modes, set it as the default map
Creating Game Mode Base Create GameModeBase Blueprint, which contains basic rules and settings for the play at each Level
Moving Player To move Player Create Player Blueprint, bind user input
Player Movement To process the movement, receive horizontal and vertical inputs to create Get Horizontal and Get Vertical vectors
Connect Normalize Node to keep the vector size as 1 even for diagonal movements