WASD - Walk and Run

Good evening,

I was hoping someone might be able to point me in the right direction, I have started the Top Down example and trying to alter it to suit my needs, have got WASD key movements working however now I want to add a modifier such as HOLD SHIFT to run. Below are how I managed to get my character moving.

Yes I have googled and searched and really cant seem to get something working, also this is my first time posting so be gentle :slight_smile:

Thanks

da1f5e2a1a629dc81e9c2c3835ced9ab09dcfa17.jpeg
1d8b4debc0de60e34e46d86d720221b70baadfcd.jpeg

As long as you don’t want to have stamina or such things, you can create an “Action Mapping” for your shift key.

Then you get the Key Event like you did with the others. Grab your CharacterMovementComponent and set the “MaxWalkSpeed” to a higher value
when the base value (you can see the base value on the right side when you select the component). Place this Set node behind “Pressed” of the key event.
Then, create a second Set Node for the MaxWalkSpeed and place it behind the “Released”. Put in the base value the player should move when
not sprinting.

If you want to have stamina reducing and such things, you would need to work with Event Tick and a bool that is true for sprinting and false for not.

You would set the bool to true or false behind the KeyEvent instead of the MaxWalkSpeed and in the Event Tick, you would reduce the Stamina variable
as long as the bool is true and add a value to it as long as the bool is false (to regain stamina). You would also check the value in the tick and set the
MaxWalkSpeed higher as the base value if stamina is greater than 0, otherwise reset the Speed again to the base value.

I don’t have much time to post pictures right now, but i’m pretty sure you will find things on google for this. I know you already googled, but to be honest,
this is so basic, this has been asked SEVERAL times (: I even answered i few of this questions in the past. Check the AnswerHUB.

Thank you very much for your help, got it working. Look forward to becoming a more active member of the UE forums.