Week 20:
HND Project
Been another busy couple of weeks with other Assignments but tor this week and next week, I decided I’ll create a “Sprint” system for my UE4 Project. To do this, I began by opening the “Project Settings” and then I went into the “Input” section, I created a new “Action Mappings” that I named “Sprint” and assigned the “Right Shift” on the keyboard to it.
I then went into the “FirstPersonCharacter” blueprints and into the “Event Graph”, when I wrote in the following code (See Below). I did this by adding a “InputAction Sprint” box, then dragged the “Movement Component” onto the graph and connected it to a pair of “Set Max Walk Speed” boxes. I then changed the value of the first to “1000” and the second to “500”, and then linked them up to “InputAction Sprint”.
This piece of
coding alone allows the Player to suddenly “Sprint” when the “Right Shift” key
is pressed down and walk usually when it isn’t being pressed. This piece of
coding, however, can be expanded upon and I did so by creating 3 “Float”
variables that I named “Current Stamina”, “MaxStamina” and “StaminaRate”.
I then wrote the
out the following code in the “Event Graph” in the “FirstPersonCharacter”. Then
created a “Stamina Bar” in a separate HUD. To do that I created a new “Widget
Blueprint”, opened it and dragged a “Progress Panel” onto the screen and the “Bind”
it. I then wrote the following codes in its “Event Graph” and its “Percentage”
graph. In effect, this code should increase the Player’s speed while decreasing
“Stamina Bar” at the same time.















