I have followed tutorial on how to make 3rd person game but I cant figure out how to implement logic if Shift is pressed nothing to do and if its not set speed to be some value lets say 100

enter image description here


2 Answers 2


I’m not sure in the scripting you’re using but shift being pressed or not is a Boolean so 0 or 1, you can set the speed to 100 times by NOT that Boolean, so if shift is pressed it’ll be 0 but if it’s not it’s going to be 100.

Speed = 100 * (not)shift_pressed_boolean

If it gives you an error when you times a number by Boolean just parse it as integer


The first thing you're going to want to do is set up an input action that's bound to the Shift key. If the tutorial you followed showed you how to set up a third person game from scratch, some of this will probably look a little bit familiar.

If I'm understanding you correctly, it sounds like what you want is to have the character sprint when you hold down shift, and to run at normal speed when you're not holding down shift? If I'm wrong, this advice should still point you in the right direction.

First you're going to want to set up an input action bound to Shift:

Go to the "Edit" menu in the Editor and select "Project Settings" Project Settings

The settings for adding new Input Actions are in the Input section, under Engine: Input Settings

Create a new Action Mapping (call it "Sprint" or something suitably descriptive. The engine doesn't really care what it's called), and select "Left Shift" from the dropdown. You can ignore the "Toggle Sprint" one I added if you're not using a controller, I just added that one for completeness, typically in most games where you can play on controller the clicking in the left thumbstick button will toggle sprint on or off, so I made a separate input action for that case.

The next step is to handle this new input in your Blueprint. Create a new Boolean variable and give it a suitable name. You can see here I've called mine "Is Sprint Active?", but ultimately it doesn't really matter what you call it as long as it's descriptive (so that you can remember what it's for later)

As you can see from this picture, when the "Sprint" action is Pressed, we set the "Is Sprint Active?" variable to true, when the "Sprint" action is Released, we sit it to false.

The Toggle Sprint action you can ignore, but it's basically the same thing for the "Toggle Sprint" action, except every time you press it, it takes the current value of "Is Sprint Active?" and flips it to the opposite value.

Blueprint Setup

This isn't pictured in the above example, but every time you modify this variable, you'll want to modify the maximum walk speed on the CharacterMovement component. This controls how fast your character can go.

In this screenshot, I have two variables here (both with "Is Instance Editable" ticked in their settings, so the values can be modified from the settings of the Character Blueprint), these two settings represent the maximum speed when sprint is off, and the maximum speed when sprint is on.

Set Max Walk Speed

This should give you a very basic version of sprint. To make it look good you can set up your Animation Blueprint to play a different running animation when sprint is active, to give you something like this (sorry for the image being a little washed out, I forgot to turn off HDR colour settings on my desktop)

YouTube Video - Unreal Run Sprint Example

  • \$\begingroup\$ So I can ignore Input Action TogleSprint ? What is "SET" set to be at upper picture. Is Max Run Speed and Max Sprint Speed just variable ? And what is SET at bottom picture \$\endgroup\$ Apr 24, 2019 at 12:27
  • \$\begingroup\$ imgur.com/a/GOVbzj6? \$\endgroup\$ Apr 24, 2019 at 12:35
  • \$\begingroup\$ This node is setting "Is Sprint Active?" To true when triggered from the Pressed pin, and false when triggered from the Released pin. If you look at the node closely, there's a little tick box on the node that shows up when there's nothing connected to the pin. That indicates the value that's being set \$\endgroup\$ Apr 24, 2019 at 13:10
  • \$\begingroup\$ Max run speed and max sprint speed are variables I added, with "Is instance editable" ticked in their settings. They're intended to allow you to configure what the run and sprint speeds should be. \$\endgroup\$ Apr 24, 2019 at 13:13
  • \$\begingroup\$ Note I didn't set up any actual values for those in my example, as I created some of this just to show what to do. 600 is probably a good ballpark for run speed, as I think that's the default speed. Sprint speed you can experiment with different values to see what feels right \$\endgroup\$ Apr 24, 2019 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .