Hi there, I’m pretty new to c++ programming, especially in Unreal, but I’m fairly well versed in blueprints. I’m trying to learn more c++ so I figured I would attempt to implement simple sprint function using the base Third Person C++ template, but I’m apparently doing something wrong and I can’t figure out what.
The equivalent in blueprints would be to use a key press/release node for something like Left Shift and then modify the player’s speed. That would only take about a minute or so to setup in blueprints. For the c++ side of things, I was doing some research and I saw people say the equivalent is
InputComponent->BindKey(EKeys::A, IE_Released, this, &Controller::AReleased);
I’ve also seen some people use BindAction, but for this I’d rather not have to go and set bindings inside of the editor. I’ve only found a couple of code snippets that people have posted and so I’ve been trying to piece things together, but no matter what combinations I’ve tried, I keep getting errors.
What I have so far in the header file is:
PlayerSpeed- a float that will keep track of the player’s speed
isSprinting- a bool that will track if the player is sprinting (for event ticks later)
What I have so far in the source file is:
BeginPlay()- an event that sets the PlayerSpeed variable to the default MaxWalkSpeed value at the start.
What I need now:
- A key press/release event that toggles isSprinting between true and false.
- A tick event that sets MaxWalkSpeed equal to PlayerSpeed * 2 when sprinting and PlayerSpeed / 2 when they stop sprinting.
I’m just struggling with the Unreal API and where some of these things are located and how to implement them because all of the stuff is located in one place in Blueprints. Any help would be greatly appreciated.