Walking after stopping from toggle sprint

Trying to make it so when you stop sprinting or get interrupted it would set its value back to walk speed and I’m trying to do it with a second movement speed after a set time just in case that layout needs to change

Hello @Jumper200091 ,
You can try the following:
First, create an Input Action and add it to the Mapping Context.



And add the following code:

in this example, I used the following values for the variables:

  • SprintSpeed: 1000
  • MaxSprintSpeed: 1500
  • WalkSpeed: 600 (default value)

With this, it should work the way you expected and you’ll be able to have control over any value you want!

Hope it helps!

oh i will have to try this out then. A follow up question would it be possible to keep the speeds as functions to limit how much is showing or would i be beating my head on a brick wall at that point?

edit: So I should have also mentioned im trying to set it as toggle sprint. Im looking to emulate something like Nier Automata.

Hello again @Jumper200091 ,
To achieve a similar effect to Nier Automata, you can try the following code.

In the Event Tick, what this does is that if the character starts moving slowly (below 500 speed), it automatically cancels the sprint and returns to the normal state,( walking).

Also, in the IMC where you set up sprinting, add a trigger of type “Pressed”.

And regarding your question, I’m not entirely sure what you mean by “keeping the speeds as functions.” I don’t fully understand what you’re trying to achieve with that.

If you mean moving all the code into a function to keep things more organized, then yes, that’s totally possible. You just need to select everything, right-click, and choose “Collapse to Function”, you can also add categories to your variables to keep everything more organized in the Blueprint.

Let me know if it works the way you expected!

so I tried a modified version close to what you gave and while everything still fires off, it still does not set the value back to walking when I stop it keeps sprinting

From what I can see, you’re not using the Event Tick (you’re using a Custom Event) basically, this is used to run something constantly while the game is running, meaning frame by frame.

Also, when you set the NextMovementSpeedIndex variable, you need to set it back to 0 so it returns to the first state, which would be walking

With those changes, it should work correctly

ok that works now and thank you for your help. Now i gotta dig around for tutorials and learn how to stop the slide and this will be perfect.