Walk This Way – A Unreal Engine 5 Tutorial

Welcome

Welcome, adventurers, to the first of many epic Unreal Engine 5 tutorials! When I first ventured into the vast realms of UE5, I was met with a labyrinth of confusion and intimidation. Though countless YouTube tutorials offered guidance, the seasoned explorers crafting them often moved at a pace that left novices like myself struggling to keep up.

But fear not, brave traveler! Enter my enchanted tutorial series, where written guidance shines like a beacon in the darkness. Here, you can progress at your own pace, and with the aid of detailed screenshots, each step of the journey becomes clearer and more manageable.

In this inaugural tutorial, we shall embark on a quest to master the basic yet essential art of character movement. Our first mission: to implement a walk mechanic. This spellbinding process can be woven into any UE5 template featuring a controllable character.

So, gather your courage and your creativity, and let us begin this wondrous journey together!

Why do we need to walk?

When we play a game we are not always running everywhere and we are also not walking everywhere. With the default presents in UE5 regardless if its FPS, 3rd person or top down. The max movement speed is the same. We can change this by creating a blueprint that is toggled by a key. When we do this the 2d blend space takes over and slows the animation or speeds it up depending on the way we go.

The Process

Start a new project or open an existing one that has a player actor blueprint for this tutorial we are going to use the thirdperson template. When you are in the engine we are going to setup a new action. Doing this will later on allow us to customize the key binding for our walk / run function allowing your player to customize what key binding they are going to use for it.

This has now been replaced by using the Input action and input mapping context system (look below for the updated procedure)
To do this we are going to go to settings and search for action mapping. We will add a new action mapping using the plus button and call in Walk/Run Toggle and for now bind Caps lock to it.

Action map and blueprint

Since 5.3.1 released we do action mapping a little bit different, no long are we going into your project settings and mapping from there. Now we are adding an Input action and adding that to a IMC (you can have multiple of these)

Now we are going to create a new input. Navigate to Content>Thirdperson>input>Actions. Right click and go to input and select input action and name it IA_Walk/Run Toggle. Once created open it and leave all the options as default and click save and close it.

Now we need to add it to our input mapping context, should be in the previous folder. Its call IMC_Default, open this up so we can add our mapping.

Use the plus button and from the drop down select our IA we just created and bind it to the Capslock key as shown in the first screenshot and make sure you save.

Next we are going to find and access our character blueprint, depending on the preset you selected the name is going to be different for this example we are using the 3rd person preset so find BP_ThirdPersonCharacter and navigate to the event Graph tab. Click in a space to add a new node and search for our action event “Walk/Run Toggle” and add it.

Instead of inputaction it will now show as enhancedinputAction IA_Walk/run toggle

Just to reiterate, doing it this way allows your player base to customize what key they use when your game is released.

Next lets take a look at how we can create our blueprint to alternate our walk/run speed. We could do this with a flipflop however by learning the more complicated way of doing it will give us a few more options later on. So lets do this with a branch or a ELSE IF.

Firstly lets create a Boolean variable and call it “walking” compile your blueprint so we can set its default value and this is up to you however I am going to leave it unticked so our default state is running.

Once you have done this we need to now add this to our blueprint and start formulating our
branch. Click and drag your variable into your blueprint and use Get. Drag off the pin and add a branch node. The Walking variable will now be the condition of the branch. Go ahead and connect our action node “pressed” pin to the branch.

Next we are going to setup our True/False conditionals, if walking is currently true that will change our movement speed down and if its false it will increase our movement speed. So lets add the Character Movement, from the top left in our components tab click and drag Character Movement to the blue print. From its pin drag out and add Set Max Walk Speed, this will allow us to alter the speed. Connect the true pin on the branch to the set and make the speed 500 (this is the default)

Now when walking is false we need to setup what to do. Once again drag off of the character movement node already in the blue print and add another set max walk speed. Position it so it is below the first this way it makes sense when we connect our false pin to it. For the value it is upto you but lets say we set it to 120. You should now see something that looks like this

now this is complete we still need to tell the walking variable what to do, so we need to drag and set our walking variable in and connect it to our top movement set and make sure its un-ticked. Do the same thing for the bottom set and make sure walking is ticked.

So compile and save so when you now play test and press caps lock or whatever is bound to it it should alternate the speed the character moves. Ultimately the speed set is up to you and what you want for your game.

Conclusion

So now, with just a press of a button, we can seamlessly toggle between walking and running, creating a more immersive experience for players. This enhancement allows them to better appreciate and explore the stunning landscapes you’ve meticulously crafted, making every moment in your game more dynamic and engaging.

Additional

We can expand upon this by controlling the speed with variables (Float) we would ideally do this if we want items, encumbrance or even a leveling system to dictate the speed at which our characters move. Just makes it a little more easier to manipulate. So Create two new variables and name them MaxWalkSpeed and MaxRunSpeed set them as a float, compile your blueprint and then edit the default value. Once done drag and get them into your blueprint and pin them into the corresponding set nodes we added previously.

Additional 2

Now we have a complete blueprint setup for Walk/Run toggle we can turn this into a function. This basically turns all of your nodes into one. This makes for a cleaner blueprint, this also makes it reference-able and reusable in any part of our game. To do this highlight all of our nodes and right click, in the contextual menu find and click collapse to function.

It will now appear on the left-hand side under the blueprints tab and we can rename it by right clicking and selecting rename. We can rename this function WalkRunToggle.

Additional 3

If you have a crouching mechanic you can also alter the speed of this using the same process simply add in your max crouching walk speed.

Leave a Reply

Your email address will not be published. Required fields are marked *