Devlog 1: Derrick Domena-Guzman: Player movement, and basic survival mechanics


Problem:
This week, I focused on implementing a player with movement mechanics and some basic survival mechanics, including health, hunger, thirst, and stamina.

Player Movement

I started by working on the player's first-person camera perspective. To achieve this, I attached a derived C++ script from ACharacter to the player blueprint, giving me more control for future implementations. I then added SpringArm and Camera components to the player and adjusted their transforms to achieve the desired view.

Player Blueprint:


In-game first-person view:

Once the perspective was set, I moved on to implementing player movement. Since the player blueprint already had a UCharacterMovementComponent attached, I created a variable called PlayerMovement for this component. I then overrode the SetupPlayerInputComponent function, binding axis inputs for mouse movement and directional movement.

I followed similar steps to implement sprinting, crouching, and jumping. For crouching and jumping, I used the pre-defined functions in ACharacter. For sprinting, I modified the max walk speed to increase when the player is sprinting and reset it to the default value when they stop.

Player C++ script (Input function):


Survival Mechanics

After completing the movement system, I added basic survival components: health, hunger, thirst, and stamina. These will later connect to the UI being developed by a team member. For each component, I created a separate ActorComponent C++ class.

Each class contains:

  • A delegate to broadcast changes,
  • A current and maximum value (e.g., CurrentHealth and MaxHealth),
  • A function to handle value changes (e.g., HandleDamage in the health component).

In the HealthComponent, I initialized the current health to the maximum health in the BeginPlay function. The HandleDamage function updates the current health value and includes checks to ensure the player still has health remaining. If health is depleted, it triggers the appropriate delegate to broadcast the update, allowing the UI to reflect the change.

Health Component C++ Script:


To test these features, I set up action inputs in the player C++ script to trigger changes, ensuring they update correctly.

Next Steps

Next week, I plan to refine the hunger and thirst systems to decrease gradually over time. I’ll also add functionality to reduce stamina when sprinting and regenerate it when the player stops sprinting.

Thank you for reading!

Files

EchoesOfCreation_V0.0.1.exe 817 MB
13 days ago

Get Echoes of Creation

Leave a comment

Log in with itch.io to leave a comment.