Game advanced level Process moving of player
Hello, my name is Lee Yeong Ho
We will learn about processing movement of player in this chapter
As learning contents, add external assets
and use it to create movement animation assets
Next, in order to control this animation
We create C class
And last, we will learn how to edit
and use animation blueprint which inherits
C class we create
Add External Assets and Create Movement Animation Assets
Then let's add external assets we will use
for adding external assets we will use
you should have materials we have distributed
Assets we need already are
distributed like this
So download from here and process
First asset we will use among these is Animations folder
So grab it and unzip it
Then you have Animations folder here
and you would have these FBX files
We will bring this to our project to use
So put this Animations folder into NetTPS
Drag and drop it into
NetTPS folder in unreal engine
Drag and drop Animations folder
to bring it here
Then FBX Import Options window will open like this
What we are going to use in here is
Click dropdown menu on Skeleton
You see this SK_Mannequin
There is SK_Mannequin
This one below is what we used on unreal engine 4
This one is mannequin character
Added to unreal engine 5, we will use this
Select this
and click Import All button
to bring it here
Then all of it has been brought
Click Save All button
To save them all
Let's take a look at character animations we brought
There are these kind of animations
and we will use them
under the necessity
And dying animation We brought these kind of animations
Next, we will change skeletal mesh
and Anim class we will use
Inside of Blueprints folder
We have BP_ThirdPerson
I already opend it but if you open it
It is opened already
We have character like this
Let's change this to skeleton we want
and some skeletal mesh
and animation instance files
to Anim instance files
There is Mesh on the left side
If you select Mesh component
There is Mesh we will use on Details window on the right
There is Skeletal Mesh Assets
It says SKM_Quinn
But I'm going to open it
and change it to SKM_Manny
Then it changes to muscular male character
It doesn't matter either Quinn
or Manny
Most important thing we use is
Go to Animation part
Animation Mode of Animation is
set to Use Animation Blueprint
and Anim Class below is set to ABP_Quinn
I'm not going to use this
but this ABP_Manny
This is why I changed it
I changed Anim Class to ABP_Manny
Now compile it
Let's move to where this ABP_Manny is
To move there from here
Next to Anim Class
There is browser icon If you click it
Then jump into the directory for that asset
If you see Mannequins folder on your Content Browser
It is located under the Characters
Under the Mannequins under the Animation folder
Right? I'm trying to use this
To make it easier for us to work
Move ABP_Manny to Animations folder
Under the NetTPS we usually use
Grab this and drag and drop
To this Animations folder
To Animations folder under the NetTPS
Drag and drop
Then select Move Here
Then under the NetTPS, under the Animation folder
We have ABP_Manny here
Alright, then we added external assets
We will use like this
Now let's create movement animation assets
Animations we have now is
Basically when you play
It doesn't have guns and just running
But the animation assets we just have added are
for the work with guns
Therefore we have to create
New movement animation assets so that we can use
Newly added animations instead of existed ones
Let's create them
with Blend Space
Click right button on here
Then popup menu appears
on this content window
On this menu, keep goes down on Animations category
There is Blend Space around the middle of it
Now click this
Then the Skeletal Mesh this Blend Space will use is
This one
Let me show you again
Right click and on the Animation category
Select Blend Space
And choose SK_Mannequin as Skeletal to use
Choose this
And name is BS, this stands for Blend Space
_PistolMove
So BS_PistolMove
Blend Space perform a role
to blend animation and animation appropriately
with the value of float, right?
So if you open this
Since there is any animation clip in this
So it has basic posture, which is called pose A
The skeletals like this, bones are tied altogether like this
and these league, connection points are
Tied as the shape of A are called pose A
Pose A is used a lot on unreal engine
or shape of T like this
In here, pose A skeletal
of unreal engine 5 is used
This is the basic posture
Animations we use
will be stored on the stage here
Add it one by one
and adjust input value to use
Then the sequence of animation that is added
How the animation will be played?
It says None on the left
None with vertical arrows
And on the bottom, between horizontal arrows
It says None
Use the value inputted here
to add animations
on these positions
And the position of animation changes depend on this value when it is added
So the value of animations is blended
appropriately depends on this
So we are going to set this values
There is Asset Details window on the left
There are Horizontal Axis and Vertical Axis in here
Horizontal Axis is related to
left and right on the bottom
And Vertical Axis means
This part about up and down
So we will set Name of Horizontal Axis
to distinguish the directions of up, down, left and right
Set the name of variable as Direction
Then it changes to Direction like this
and for the Vertical Axis
set this to Speed
Then it means speed, the velocity of running forward and backward
And forward animation, running animation
walking animation, I'm going to process to play these animations
appropriately
First, then what kind of values
This Direction and Speed would have
The range of these values is from 0 to 100 for now
As you can see, it is set from 0 to 100
But for the case of our character
It's in the BP_ThirdPersonCharacter
If you take a look at Walk Speed of Character Movement
Max Walk Speed is set to 500
which means this one is able to run up to 500
So we have to apply with this value
Here is set to 100 now
So in the BP_ThirdPersonCharacter
In the Character Movement Component
The value of Walk Speed, now I'm going to make it to be adjusted by this value
My Max Walk Speed is set to 500
Change it to 600, maximum 600cm per second
Move in cm units in unreal engine
I made it available to move like this
Set Max Walk Speed to 600 in BP_ThirdPersonCharacter
So next, come back to BS_PistolMove
Now then this is not from 0 to 100
This can run up to 600
on Maximum Axis Value
Then maximum of this is 600 now
On the Direction part
on the bottom, it is 600 now
It changed to 600
So when it run towards left and right
Towards right is 600 now
So towards left is -600
So that it can be from -600 to 600
Make velocity toward both left and right consistent
Now same for the Speed
Set the value
of Minimum and Maximum
to -600 and 600
Now over here
the Grid Divisions is set to 4
So the stage is divided into 4 like this
Right? In a horizontal position
I'm going to divide into smaller pieces
I'm setting this to 6
Same for the Vertical Axis below
set Grid Divisions to 6
Then you can see the stage is now divided into 6
So the basic settings for values are done now
Let's add animation sequence
Do you see Asset Browser on the right
If there isn't, click Asset Browser on Window menu
Then you will have it
On the Asset Browser on the right bottom
We have search filter
says Search Assets
I'm planning to use mf_pistol
use only these animation sequences
You can see several animation sequences here
There is green x mark on the middle
Here at 0,0
Let's add animation for standing still first
There is MF_Pistol_Idle_Hipfire on the top
Add this animation sequence and put it here
Grab it and drag and drop to put it like this
It doesn't go to the center point
It's hard to grab and drag it
But grab and drag it while pressing Shift
It sticks to them
It moves on the gird intersection
Keep pressing Shift when you put it in then it goes on the intersection
So you can see now Idle animation is
playing on this preview viewport window
At the center point
I put Idle_Hipfire animation sequence in
by drag and drop with pressing Shift
Next, when this character moves toward left
Now it's from -600 to 600
I'm going to add animation sequence moving left first
Jog is running and Walk is walking
Grab Walk_Left and put it
Here with pressing Shift
Then put Walk_Right in
Then Walk_Fwd here above
Then Walk_Bwd here
Then it forms a diamond shape
Let's put Jog in this time
All the backward, forward, left and right for Jog are here
Add left first
Keep press Shift
and drag it here then it sticks to the intersection on the edge
Then Right with pressing Shift
Then Jog_Fwd on top
Then Jog_Bwd on bottom
Put them in like this
If you hover the cursor
Then it show us which animation sequence is playing on that point
In order to preview it
You have to move this green x mark
Press Ctrl on keyboard
Once you press Ctrl then you can see
X mark follows your cursor
On the stage
If I move to the left, it goes to left
If I move to the right, it goes to the right
and upward and downward
Wait, I said left but isn't it moving to the right?
Do not think that way
You see like this on actual screen, forward from the back on viewport
So when I move to the right, then right like this
and left
and forward
and backward
Now then save it
and close BS_PistolMove
Work is done
That's it for creating movement animation asset
Creating C Class and Editing Animation Blueprint
Now let's create C class
for control
ABP_Manny, BS_PistolMove we created
to control these appropriately
we need control class
So create a C class
to settle this
Move to C Classes folder on Content Browser
and click right button
And click New C Class
As parent class for the class we will use
choose All Classes
and search
AnimInstance here
Then you get AnimInstance
Choose it and click Next
For newly created C class
There is Public and Private button on Class Type here
If you look at the path
Where header file and cpp file
will be created
We made two type of folder when we created project
which are Public and Private
So automatically create them in there
Class Type of the new things
There are Public and Private
So basically header file goes into Public
and cpp file goes into Private folder
So make it like this and set
Name of this class file to NetPlayerAnimInstance
Then click Create Class
Then NetPlayerAnimInstance class is created on Visual Studio
and choose reload all
So everything is created and compiled
Now I'm going to add new property
at NetPlayerAnimInstance
That's because we added new animation
There are animation holding guns and
animation without guns
If you play it, it doesn't hold gun now
In order to tell when the animation with guns should be played
in order to tell this
I'm going to add member property
So move to NetPlayerAnimInstance header file
You can find it on Solution Explorer
Double click NetPlayerAnimInstance header file to open
In here, let's add
Whether player has a gun or not as public
Let's add member variable remembering
Whether the character has a gun or not
Set type to bool
bHasPistol
It won't have it so assign false
But I want this value to be connected to blueprint to work
Then this member variable in C class
needs to be introduced to unreal engine
So in order to let unreal engine know
Type this
UPROPERTY(EditAnywhere)
Then this bHasPistol can be edited from anywhere
This would be in unreal engine
Then this can be read and written from Blueprint
Then Category
For category bHasPistol will be exposed
I'll say MyAnimSettings
Then when it is shown, bHasPistol will be shown
under the MyAnimSettings category
This type of setting is called reflection
In object oriented language, in language which has virtual machine
Such as C# or JAVA
This part is done automatically in some degree
But C based language such as Unreal Engine
In order to connect this properties I have
to Unreal Engine or other things
We have to use some technique to solve it
These are called reflection
and where all these part is saved to
is NetPlayerAnimInstance.generated.h file
Information about this class
go up to there in the form of UCLASS
Base on those information, unreal engine
know what kind of information is in this class
what properties and funcions are in here
and it can use them
But it can not use them without any condition
Property needs Macros function called UPROPERTY
and function needs UFUNCTION
And I finished to add like this
Then let me build it once
Normally, after compile
You should let unreal engine know about header
For constructor file
For constructor function, if it is edited
You should let unreal engine know
Basically it is automated to be notified
Via function called Hot Reload
It is updated automatically
But there are many cases not working well
Such as this
When the property is added to header
or change this value on header
There are many cases editor doesn't notice
This value has been edited
So usually, when some values
are added to header or so
It's good to close and restart the editor
When you are working with Unreal Engine
So restart it
Then as unreal engine start
All the added or edited things are reflected normally
Commonly, some function logic we work
are reflected well when we edit it
But when we change or add
Values of properties of constructor function or so
It's good to restart the unreal engine editor
In here, double click
to open this ABP_Manny
Which is in Animations folder under the NetTPS
Open it like this
Now what is the parent class
of this ABP_Manny
If you look at right top
It says AnimInstance
It says Parent class is AnimInstance
It's not NetPlayAnimInstance we created
Parent class is set to AnimInstance class which is just the highest class
So we have to change it to what we created
So go to Class Settings, this button here
Click Class Settings button
There is Parent Class on Details window on the right
Change this AnimInstance of this Parent Class
to NetPlayerAnimInstance class
we created
Now if we go and look then
This member variable bHasPistol, this property we added
has to be shown under the VARIABLES
On My Blueprint window
If you can't find it, then you have to add it
There is gear icon on My Blueprint
Click it
Then there is Show Inherited Variables option
This is the option to show variables of parent
Check this
Now we have My Anim Settings on My Blueprint
Under this category, property Has Pistol
We added is shown
This was the content
to create C class to control
Now let's edit animation blueprint
By using this Has Pistol we added
Let's edit animation blueprint
Here is AnimGraph
There is AnimGraph tab in ABP_Manny
Or if you can't find it, then go to My Blueprint
There will be AnimGraph
Here is AnimGraph on My Blueprint
Double click it to open it
Then it is opened
There is Locomotion node
Double click it
Or Locomotion under the AnimGraph
You can double click this, it's same
If you double click Locomotion
Then you can get in to Locomotion tab in AnimGraph
in ABP_Manny
Idle animation and Walk and Run
Walking and running animations are
Working normally
by using state machine
When player has pistol we add
We can't use this for walking, running
and standing still animation
Therefore we have to add and create one
So here is Entry node
Disconnect this transition arrow from Entry node
to Idle by pressing Alt and left click
It can not go towards this regardless of condition
Here is where animation is played
And FSM state machine is working when player has no pistol
When player has pistol, we'll make something else execute
Then there are 2 cases
When player has pistol or has not
Therefore in order to process branch
Some technique is added to Unreal Engine 5
If you click right button
There is Add Conduit Let me explain it
As you see
This pipe, tube thing is conduit
This is called conduit
and some animation we want to use
is not only go to one direction
But want it to flow
through these pipes
So add Conduit node
and name of this Conduit node
is Has Pistol
You see there is icon
It looks like duct, pipe
So this can decide destination
depends on input signal
So connect Entry node
to Has Pistol
Then connect Has Pistol
to Idle like this
Then when player doesn't have a pistol
Then upper one will be played
There is Asset Browser on the right bottom
If you don't see Asset Browser as well
Choose Asset Browser form Window menu
Search BS_PistolMove we worked
Find BS_PistolMove we worked
and drag and drop to add
BS_PistolMove is animation with pistol
Grab Has Pistol
and connect to this
Then when player doesn't have a pistol, animation above will be executed
and when player has a pistol, below one
will be executed
Then here
There is a case we have to go back from Idle to Has Pistol
We didn't have a pistol and we pressed grab pistol button
Then we have to grab pistol
Then below one has to be executed
In other words, running with nothing then grab pistol
Then animation below needs to be executed
Not above one
So go back from Idle to Has Pistol
and from Has Pistol to here
And another case
Moving with pistol then drop pistol
Then animation above needs to be executed
So go back from BS_PistolMove to Has Pistol
Then go to this way
This structure needs to be made
This Has Pistol node
Double click this Conduit node to open
In this Conduit node
It says Can Enter Transition, this is option
Whether you'd like to make this transition work normally or not
I'll check this to make it work no matter
Again, double clicked Has Pistol node from Locomotion
Then it means start from entry through Has Pistol node
Make transition to go somewhere
So check Has Pistol node regardless
to make transition go
Then back to Locomotion
When transition go from Has Pistol to Idle
And when it go from Has Pistol to BS_PistolMove
When not holding pistol, go to Idle
There is rule here
There is this rule, condition button of transition
Double click this to open
Then the condition transition have to go from Has Pistol to Idle is
Has Pistol on My Blueprint on left bottom
is member variable about whether or not player has a pistol
How is it if it doesn’t have a pistol
It needs to be switched to default animation Idle without pistol
So the value of Has Pistol
I pressed Ctrl to add it like this
Grab data pin and pull
and type !
Choose NOT Boolean when it is not
This value proceed when it is not
Transition go from Has Pistol to Idle
When player doesn't have a pistol, let's process this way
Back to Locomotion
Then when transition come back from Idle to Has Pistol
How is it when player holds a pistol
Transition have to go this way
Click this condition button on Has Pistol
When is it this time, when Has Pistol is true
When player have a pistol it has to come back from Idle to Has Pistol
Come back to Locomotion
This time from Has Pistol to BS_PistolMove
How to go to the state having pistol
When having pistol, this condition button of transition
Double click it again
Put Has Pistol variabel
to Can Enter Transition like this
Then come back to Locomotion
Transition needs to go from BS_PistolMove to Idle
So it's when Has Pistol is not
It has to go this way when player doesn’t have pistol
So this time, select condition button
towards Has Pistol node and double click
Bring Has Pistol node again
When it's not, !Not Boolean
Connect like this
Then Locomotion looks like this now
Compile it and how is it?
It became like this as we save it
If you see this, how is Has Pistol
It says cannot be used
On Entry node, how it happens
There is AnimGraph
Let's move AnimGraph node again
After move to AnimGraph node
Select this Locomotion
Select Locomotion
On Details window on the right
Under the Settings category
There is Allow Conduit Entry States
Option asking about using Conduit as Entry States
is unchecked, if you check it
You can use it
Click compile button again and now it's normal
How is it now? It's working
We can keep this part
And there is a thing we should think about
So let's do it one more
Go back to Locomotion
in Locomotion again
Let's say it's running on Idle
Running without pistol
We pressed grab pistol button while running
Then it has to be changed to grabbing animation
But if you see current state transition
From Idle, transition can move through Has Pistol
But Walk and Run don't have a way to go
It has to go back to Idle
But player is keep running so it will be running state
There is no way to go to here
When you are not holding pistol, no matter what state is
If you grab pistol, you want to move to here
To settle this
We can add and use node called State Alias
No matter what state is, help us to move to the state we want
Let me add this
Click right button
There is Add State Alias
Choose this to add
Set name of this node to Any State
In any state, such as while running
Grab a pistol in any state
I want to make it move to here
and it can only move from Idle now
But in this state, make it able to move to BS_Pistol
I want to process that therefore Any State
Make it able to go to BS_Pistol from any state
That's what it is
Select Any State and go to the right
On Details window
When do you want to go to BS_Pistol
BS_Pistol doesn't need to go to itself when player already holding a pistol
When running
Let's just check Idle as well
Then when player doesn't have a pistol
I made Any State can be enabled
Global Alias includes all of the states
We chose Any State and checked Idel, Walk and Run
That's good
Condition that Any State can be enabled in any state is good
Then we need transition condition for Any State to go to BS_Pistol
So that get signal in any state
and go to BS_Pistol
So select this transition button
When this should active
That's when Has Pistol is true
When player has a pistol if this signal comes in
Then make BS_Pistol work right away
If player doesn't have a pistol then automatically
Go to Has Pistol then to Idle
Click compile button
Now everything set correctly so let's test it
Here is Anim Preview Editor
If you don't see it then there is Anim Preview Editor on Window menu
Click this to open window
To test about switching animation
When player has a pistol
There is Has Pistol on Edit Preview
Check this then it grabs a pistol
You could see it on preview viewport window
Has Pistol
We are at here now
If we check and uncheck Has Pistol here
Then this value would change on this preview window
Let me uncheck it this time
Check it, uncheck it
You can see it's working well
Now if you have edited animation blueprint like this
Make this little bit more
able to extend and use animation bluprint
Add velocity on running
Add stuff to make velocity
applied to BS_PistolMove on left and right
forward and backword
If you go into BS_Pistol
It has no value of Direction and Speed for animation to switch
Some value has to given to switch animation
But it doesn't have that part now
So let's add that part
Animation blueprint need little more of edited content
and that is here
In here, we need Speed and Direction
to control animation
So let's add that part here
If you press Ctrl D one line is duplicated
I duplicated this
In here, I'm going to give value
of left and right first
Write float direction
Press Ctrl D once more and float speed this time
Then what we are trying to use here
What we are trying to use in BS_PistolMove
We declared variables correspond to Direction and Speed
Build to apply this value
Once you build it
When this is added, usually we need to restart editor
But I think it could be work normal using this window
If you think errors are occur, then restart editor
Usually just restart it as if it is a habit
It's good for you when you work like this
Whenever you work with engine, even if it is annoying
Shut down and restart apps frequently
is a help on preventing errors
It is applied right away so we're just going to continue
Drag and drop to attach
Direction to BS_PistolMove
and drag and drop to attach Speed to here
Then value of Direction and Speed
We declared as member variable
can be applied on BS_PistolMove noramlly
Compile it
If you want to see how it work when the values are changed
We have Anim Preview Editor here
Change those values here
If you change this value, wait nothing changed
That's because Has Pistol needs to be checked
Once Has Pistol is checked
You would be able to see it moving
It can move backward
If you change the value to minus
It can move forward
You can see this visually
If you uncheck Has Pistol, it's not applied
Then to make these values of Direction and Speed applied
We will add to script
Let's edit C class
Go to Visual Studio
First, the animation is, we have to take
values from character
through NetTPSCharacter to apply to animation
such as how fast the character is
running right now
Take velocity and process or so
So we need a way to have this NetTPSCharacter
As member to get values from there
and use it
Therefore add instance
of NetTPSCharacter
As member variable here
Write class ANetTPSCharacter* player
to add variable player as the type of ANetTPSCharacter*
When the pointer is attached
In order to get memory managed by unreal engine
Add UPROPERTY()
Now then when the player reference become 0
When reference counter hit 0
Then my player character itself
is removed from memory
by Unreal Engine
You have to add UPROPERTY() to pointer
We need place where this player is assigned
and Direction and Speed will be assigned
stuff like that
In order that let me add
2 lifecycle function
public:
First, add virtual void NativeInitializeAnimation function
Which is similar to BeginPlay function
This function is called when this class is called
at the beginning
Next, virtual void NativeUpdateAnimation
We will override these 2 functions to use
InitializeAnimation is called once
and UpdateAnimation will be called
progressively while animation is playing
just like ticks
Add implementation block
of NativeInitializeAnimation to cpp file
NativeUpdateAnimation from header file
Add this function as well
Implementation blocks are added in cpp file
These two file have things
to process by calling internally from parent class
Therefore overridden functions
have to add Super
And call NativeInitializeAnimation
parent have
Same for below, add Super and NativeUpdateAnimation
to get processed
this part
First, NativeInitializeAnimation
This is initialization function
This function is about how it would be initialized
When this NetPlayerAninInstance class is initialized
In here
I will initialize instance
of NetTPSCharacter here
Initialize instance
of NetTPSCharacter
Which means I will get and use it
This NetPlayerAnimInstance is ABP_Manny
Because parent class is NetPlayerAnimInstance
Then the class having this ABP_Manny is
BP_ThirdPersonCharacter blueprint class
Why?
If you look at Mesh Component from Components
It is using ABP_Manny as Anim Class on the right
Which means this character is using this class to control this animation
Therefore bring NetTPSCharacter which this is owned by
and process velocity and so
So let's process initialization here
This is instance on header file
Like this
This player is not assigned anything
It's nullptr
Let's assign value to this
Cast to assign to player
ANetTPSCharacter*
and we need to pass pawn
which owns this animation now
Call TryGetPawnOwner
To get this and
Cast into ANetTPSCharacter
and assign it here
Since this is
not included to this file
If you compile then it occurs error
Therefore add header file
on the top like this
Build it once more
Now that build is succeeded
In NativeUpdateAnimation, get current velocity
of this player to character
and assign Direction and Speed
In NativeUpdateAnimation function
It is possible only when player exist
Let's say we got values but there is no player value
Then it occurs null pointer error
In order to process only when the player exist
If player is not nullptr
You can do like this
To make it simple
This let it process only when the player exist
In here I will get Speed value
and Direction value
Value of Speed can be gotten like this
speed =
First, player's
I should explain it more in theoretically
Let's say player is standing like this
The direction in which this character is
Currently heading is
is this way
Character is moving towards this way
Then when it's moving like this, this value
will be speed, the direction
Then direction of left and right is
If this character is moving like this
Then direction of left and right
will be like this
This and this direction for left and right
When you consider this as criteria
Then this velocity vector as criteria
How to get this speed related to the front
and direction related to left and right
Then what we need is
Inner product
And how to get it
Character is heading this way
But where this character is facing now
It's facing this way
Then we want to press key to move toward this way
Then character is facing this way
and moving a bit diagonally
Currently moving diagonally
Then from here, left and right vector
Direction vector, left and right vector
We commonly call it right vector
Then consider this character as criteria
With this velocity vector
We have to implement forward vector
Use this vector
And get forward and right vector
This character is moving like this
It’s moving like this on drawing
This character is facing this way
But moving towards that way
When character is moving
And facing this way, make this way as criterion
Get forward and right vector
Then how can we
Use this velocity vector
This is velocity vector
Use this velocity vector
To get forward and right vector
This is how we should implement now
So that we can get speed value
And how fast it is when it move forward
How fast it is when it move left and right
How big it is
We can get it using inner product very easily
Velocity has value of x, y and z
Let's say this V for velocity
F for forward vector
And this have value of x, y and z as well
To get inner product, multiply coordinates with same index
Multiply coordinates with same index
When you get inner product, multiply coordinates
With same index first
Therefore we get it
in VxFx VyFy form
Forward vector this character facing
Let's say forward only have one coordinate x
Then we can get it
Only with x coordinates like this
Therefore we are going to get velocity and forward using inner product
Or use inner product to get velocity and right
and use these two to get direction like this
Inner product from velocity and forward will be speed
and inner product from velocity and right will be direction
Let's process this part
So write speed = FVector::DotProduct
and first parameter we pass is vector
So get velocity from player
Then we get one vector
And we need float speed which is scala value
So dot product this and forward vector of player
Dot product these two
Then from this velocity vector
And direction character is facing
We can get size, velocity
and same for the direction
Press Ctrl D to duplicate
For direction, velocity is same
Get vector from player and get direction
Then let me build it
Go to Unreal Engine
Character is currently like this
And it's okay on animation as well
Currently it doesn't have a pistol
So even if we give direction and speed value
It won't be played properly
Animation existed is playing
When it doesn't have a pistol
To make animation processed
When it has a pistol
Go to Anim Preview Editor
Check Has Pistol
And on the bottom in yellow
It says Changes made to preview only
Click apply
Then this will be remain checked while we proceed
Click compile button
Then this animation is
Keep going to have a pistol
Of course in here
On C class, you can set default value to true
To test this
But simply in here
Just check this and click apply
to test this
Now come to main editor and click play button
Animation starts with a pistol
Now let's move character It's moving
You can see it moving backward, left and right
But this animation moves as if it is teleporting
Why is it like that
In the value of motion of animation we brought
It contains actual transform of animation
It contains location, rotation and so
So let's edit these animations little bit
Those like MF_Pistol_Jog_Left
Let's edit these
On BS_PistolMove
Open it and edit it
Type mf_pistol
To search what we use
Double click Idle_Hipfire
Double click this to open
Then on Asset Details
Search root on Asset Details on the left
The reason it is modified is that there are transform values
of animation are in the RootMotion
Such as location and rotation
Check Force Root Lock
To lock Root forcibly
So that they can't be applied
Save it
Check Fore Root Lock on Jog_Bwd as well
Then it is running on the same spot
Save it
And same thing goes for the rest of them
Check on Jog_Fwd and save it
Check Left, save and check Right, save
Check this on Bwd, Walk as well
It's all done now Close this
Go back and click play button and move
Then you see it's moving properly now
Move forward and backward
You can see it is switched normally
to animation with a pistol
That's it for processing movement of player
Added external animation assets we used
Created movement animation assets
And created C class
Edited animation blueprint in general
Let's put together what we learned in this chapter
Add external assets and create movement animation assets Add external assets on the project and assign skeletal information you want to use
Add animation to change motions depends on the values of Direction and Space by creating Blend Space
Create C class and edit animation blueprint Create NetPlayerAnimInstance C class to control animation and implement animation blueprint control logic of player
Branch process when there is a pistol and not by using Conduit node on animation blueprint
Create transition which is able to be executed in any state through State Alias node
Use inner product of vector to get forward and right direction and get speed with forward and right and apply to Direction and Speed on Blend Space