Currently I have a character with a normal walk speed, who can sprint if you hold shift. However, I only want her to run forward and not side to side and back. How would I go about doing that?
I tried setting the speed right after the input axis events, but it didn’t produce the desired result.
I’m surprised that setting the speed on the strafe inputs did not work. Maybe hitting shift after you start the right or left strafe overrides the speed setting you just set so the speed goes back to sprinting speed? You may need a bCanSprint variable that is set to false on strafe key press and true on strafe key release so that the shift key press logic can check this before changing the speed. Obviously, I’m doing a great deal of guessing at what your blueprint and control scheme looks like, so this may or may not help.
As you can see, the normal walk is at 220 and the run is at 1200. When I had the “set speed” in each of the forward and right events, it only seemed to respect the 1200 setting. I am pretty sure it is because they are fighting with each other, so right now I only have “set speed” in the AxisRight event. I know what I have in the image is not the right way to do it, because I need the speed the character to be at 220 (Walking), if shift (which makes the run normally) is pressed while the character is strafing. Does that make sense?
It’s hard to tell what is to the right of that, but you may want to make left shift press/release toggle a bSprint variable and then, in the InputAxis MoveForward execute path only, set the Max Walk Speed to 1200 if bSprint is true, 220 if false. Give InputAxis MoveRight its own execution path that is not connected to the InputAxix MoveFoarward execution path and always only with a Max Walk Speed of 220.