Changing Movement Speed/Sprinting

So after running through the FPS tutorial on the wiki and seeing how it runs through basic inputs yet doesn’t explain what to do if you want to add your own custom binds which do anything else, I noticed that it’s missing any form of sprinting/crouching.

I assumed the Value part of AddMovementInput(Direction, Value); would change the speed, after testing that straight from the input menu it just seems to set the axis, which makes sense

So the actual question is, how would I change the max speed through C++ itself, every answer I have found on here is with blueprint.

Also, I come from Unity so the major differences between C++ and C# are things I need to work on, sorry if this should be obvious.

You should be able to do something like:

CharacterMovement->MaxWalkSpeed = RunSpeed;

Yeah, thought I was just being stupid and still need to learn the basics like this.
Thanks!

That doesn’t work…you have to use

GetCharacterMovement()->MaxWalkSpeed = RunSpeed;

Small difference I know

Im really confused. I used that myself, but its not working:

 WalkSpeed = 200.0f;
 RunSpeed = 600.0f;
 GetCharacterMovement()->MaxWalkSpeed = WalkSpeed;

It uses that at the beginning of the function. But I’m not seeing the change in game?

Hey,
As i noticed changing maxspeeds are not replicated, but engine does two side check.

That means engine check maxspeed on client and on server too.
If server have bigger maxspeed as client, client will restrict their movement speed no matter if server allowing bigger movement speed.
If client have bigger maxspeed, server will restrict because player cant move faster as server allowing this :slight_smile:

Im not sure you do multiplayer game also im not sure is thisan engine bug and can happen in standalone mode, but in my multiplayer game i run into a same problem.
I called a server event, modified walking speed and just nothing happend.
After then i made a server event, but before sending i modify speed on client too (so in theory server and client have same speed) and magicalky works :slight_smile:

I do not tried in standalone/single player mode, but i guess in single player mode this bug not will happen.
Any other mode listen servee, dedicated server maybe can be :slight_smile:

But make a try :wink: