Multiple ways to control Player Character Walk Speed;base64
​​Hi Guys,

I’m currently developing a side scroller game on very early stages and I’m new to game development. At the moment, I have a main character able to switch walking speeds via 2 different keybinds:

Default speed: WALKING
**Press Caps Lock: **JOGGING (press it again, back to walking)
**Press Shift: **RUNNING (press it again, back to walking)


The above solution is not really what I wanted as it can be very cumbersome to deal with. Ideally I want 2 ways to be able to control the character speed:

  1. Using a single key to toggle between all 3 stages ( WALK / JOG / RUN )
  2. Gradually increase/decrease the character speed by turning the mouse wheel up and down

Does any of you guys know a way to do the solutions I’d like to have in my game by using blueprints?

Thanks in advance!

For the first one, Make an integer variable and add increment code to the input action. So when you press toggle, using branches, it’ll check what number you’re at [0] and add 1, setting walk speed to next state.
You hit it again, [1] and itll add 1, setting walk speed to 3rd state. You hit it again, and it’ll go through your branch, and see that integer == 2, so it sets integer back to 0 and walk speed to original state.

For the second one, get [mouse wheel up] and [mouse wheel down] input events. When you scroll mouse wheel up, it’ll fire every “tick” of the scroll. Create a walk speed variable to plug into the set walk speed node and increment that, setting walk speed after.

ex(every mouse scroll up you add 10 to the walk speed float variable, and then set Max walk speed to w/e that float variable is off the same mouse scroll event) Make sure to add branches clamping the speed at a lower end and an upper end. Branch–> if walk speed variable would be <100 do nothing. if walk speed variable would be >500, do nothing. Put the clamp before the increment so it wont even try to add to the float variable and mess up the numbers.

Thanks for your reply [USER=“3543726”]Moist Polio Legs[/USER]

I will try to do this using your approaches mentioned above!

My only question is. How can I check 3 different values using a branch, when the branch only allows for 2 different outcomes (True or False)?

Do I just use 3 different branches from the same node?