Different walk and run speeds

I want my character to walk and run at a different speeds. So if the player moves the thumbstick between 0 and 0.5 the character moves at a speed of 200 but if the player moves the thumbstick between 0.5 and 1 then the character moves at a speed of 500.

With my current setup the speed is dependant on the thumbstick value. so if the thumbstick is at 0.5 the character moves at 50% the max walk speed set in the character movement componant.

I’ve just moved from Unity so i’m very new to all this and have been following various tutorials so far but can’t find anything on this. Any help would be greatly appreciated.

2 Likes

If you moving to UE, move to version 5, don’t stay at 4.

Sorry I didn’t mention. I am using UE5.

InputAction and InputAxis is deprecated.

Use Enhanced Input

As for speed change. You need it to be only 200 and 500?

If so:

1 Like

Hi @MarkAntony88,

Welcome to the Unreal Engine forums.

I believe a “Curve Float” would help you in this situation. You would set you max walk speed to 500 and plug the movement into the curve. This way you can tell it at 0.5, the value should be 40 % of the max (200 / 500) or 0.4.

  1. Create a Float Curve:
  • Right-click in the Content Browser.
  • Navigate to Miscellaneous > Curve.
  • Choose “Curve Float”. Name it and open it to define your curve.
  • Adjust the curve to shape the kind of movement profile you desire.
  • Key points (0,0) (0.5,0.4) (1.0, 1.0) Just double check these
  1. Integrate Curve in Blueprint:
  • Open the Blueprint where you handle movement.
  • Add a variable of type Curve Float, and set its default value to the float curve you’ve just created. (You need to press compile before you can change the default value)
  1. Query the Curve:
  • Use the “Get Float Value” node to get a value from the curve. The X input will be the value you’d usually input linearly, and the output will be the corresponding Y value from the curve.

Hope this help.

1 Like

Could you please explain what all the nodes are doing so I understand how it’s working and how I would be able to make full movement using those nodes. Even in unity I was much of a programmer so really don’t understand.

IA_Move is Enhanced Input, you can read about it in link I posted.

“>” is a boolian operator, what it does I think you know.

“+” takes this 2 bools and adds them up (true = 1, false = 0).

Based on that we can deside needed option using Select(it’s sort of “case”).

For example:

Value X is 0.3, so it’s > than a 0 (true), but not > than a 0.5 (false).
True(1) + False(0) = 1.
1 in “Select” is 0.4.
Max walk speed is 500.
500 * 0.4 = 200.

Thank you for the explanation, I understand how better how it’s working now. I’ve turned it into full movement now (Forwards/Backwards, Left/Right) but it’s not working as intended. the charcter will not move straight forward, only slightly left or right and the walk speed is 282.842712 Is this the correct way to set this up or have I just made a complete mess of things.

Use Get actor forward/right vector
Do not break it

Doing this just makes the character spin in place instead of moving

Here expanded:

Y was forward, not X.

ABS to remove “-” from the float.

Ok, forget this mess.

I made much better.

Enhanced Input has user curve modifiers

First, make a curve:

Constant is a bit junky, so you need 2 extra points to fix it:
Points: [ 0; 0 ], [ 0.001; 0.4 ], [ 0.5; 0.4 ], [ 0.501; 1 ], [ 1; 1 ].

Then add to 2 more points and make them constant: [ -0.5; -0.4 ], [ -1; -1 ].

Then go to your IMC
image

Adding modifire. You probably already have modifiers there: Dead Zone and Scalar.
You need to add one between them. You can use Insert:

Add Response Curve - User Defined and set X and Y to your curve:

This is how code should look after:

UPD: Dead Zone Fix.

Need 2 more points for a “Dead Zone”: [ 0.2; 0 ] (also move [ 0.001; 0.4 ] to [ 0.201; 0.4 ]) and [ -0.2; 0 ].

Remove Scalar Modifier.

It’s still not quite there. It works when I move forward but the character won’t turn when I move backwards and it spins in place when I move left or right.

Oh. In this case remove get actor foward/right vector. For left/right X:0 Y:1 Z:0. For forward backward X:1 Y:0 Z:0

Ok that works but now forward is backwards when the camera turned

Show me.

So i push the thumbstick forward then i move the camera round and push the thumbstick forward again. so the character no longer rotates based on which way the camera is facing.

Try this:

Fixed it by getting control rotation to right and forward vector. now works perfectly.

Thank you for all your help with this.