2 Phase sprinting problem

Hy guys. I’m still a newbie in unreal (used unity before, but I needed to move to UE, as the effects here are just amazing). Currently I’m stuck at a problem and I don’t know how to solve it, if someone can help. Basically, what I want is to make a 2 phase sprint. If you press and hold shift, you sprint. If you press twice and hold it, you get in phase 2 sprint which is much faster. Also those sprints will have 2 different bars for “stamina”, but I still didn’t integrated them.
So, about the problem. When I press and hold shift, it sprints normally. When I release it, the char walks. Everythink ok until now. When I double-press + hold, it sprints for a couple of frames (less then 1 second) and after it, char is getting to normal speed like I would release the button.

vvcap 2016-03-26-11-33-40.png

The above photo is my blueprint system. Basically, what I want is that when it checks for 2 press, and the button is still pressed, it would 2phase sprint until, well for now until you release :smiley:

Hey terror2012,

the problem lies in the delay node after the release exec pin. When you switch from sprint level 1 to level 2 by pressing shift again, you need to release it for a very short moment. So .3 seconds after this release, even if you are in sprint level 2, you switch back to 0.

I set up a layout myself which handles this problem:


The macro ‘UpdateWalkSpeed’ is quite straightforward and looks like this:


I hope it’s clear what the BP does through the comments. The only drawback is, that getting out of sprint level 1 into level 0 takes .3 seconds, whereas getting out of level 2 happens immediately.

Hope it helps a bit.

When you release the key for the first time before you press it twice, you enter the Released logic, which after 0.3 second you set the number of press to zero again. That’s why you are having it to reset even when entered the phase 2 sprint.

I’ve made one solution here and it’s working fine:
forums 00.png

I’ve set great values of speed just for testing. There’s no need to use the bSprint1Started for this logic, but if you want to have control of you character states, I’d recommend you consider this variable.

Tell me if this solution has worked for you.

Didn’t see someone has already posted a solution, sorry. Well, now you can choose between 2 :slight_smile: