);}// [AI] Implementing movement…void APlayerController::MoveForward(float V) {if (!FMath::IsNearlyZero(V)) {AddMovementInput(GetActorForwardVector(), V);}}void APlayerController::Jump() {if (ACharacter* C = GetPawn<ACharacter>())C->Jump();}void APlayerController::Tick(float DeltaTime) {Super::Tick(DeltaTime);UpdateCameraRotation(DeltaTime);SyncNetPosition();}// [AI] Unit tests…TEST(PlayerControllerTest, MovesForward) {auto* PC = NewObject<APlayerController>();PC->MoveForward(1.0f);EXPECT_TRUE(PC->IsMoving());}// [AI] Generating: PlayerController.cpp#include "PlayerController.h"#include "Engine/GameEngine.h"#include "Components/InputComponent.h"APlayerController::APlayerController() {bAutoManageActiveCameraTarget = true;bEnableMouseOverEvents = true;InputYawScale_DEPRECATED = 1.0f;}// [AI] Binding input axes…void APlayerController::SetupInputComponent() {Super::SetupInputComponent();InputComponent->BindAxis("MoveForward", this,&APlayerController::MoveForward);InputComponent->BindAxis("MoveRight", this,&APlayerController::MoveRight);InputComponent->BindAction("Jump", IE_Pressed, this,&APlayerController::Jump);}█
Create a PlayerHealth component for Unreal with damage, heal, shield and death delegate.
Analyze PlayerCharacter.cpp for existing health refs
Generate UHealthComponent class (header + source)
Add shield mechanic with absorption rate
Wire OnDeath delegate to GameMode
Write unit tests
Here's the full `UHealthComponent` implementation with damage absorption, heal-over-time, shield layer, and the `OnDeath` multicast delegate:
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class ARENA_API UHealthComponent : public UActorComponent {
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Health")
float MaxHealth = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Health")
float MaxShield = 50.f;
UFUNCTION(BlueprintCallable, Category="Health")
void ApplyDamage(float Amount, AActor* Instigator = nullptr);
UFUNCTION(BlueprintCallable, Category="Health")
void Heal(float Amount);
UFUNCTION(BlueprintCallable, Category="Health")
void RechargeShield(float Amount);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(
FOnDeath, AActor*, Victim, AActor*, Killer);
UPROPERTY(BlueprintAssignable)
FOnDeath OnDeath;
UFUNCTION(BlueprintPure) float GetHealthPercent() const;
UFUNCTION(BlueprintPure) float GetShieldPercent() const;
private:
float CurrentHealth;
float CurrentShield;
bool bIsDead = false;
};Applying HealthComponent.h to project
Written to Source/Arena/Components/HealthComponent.h
Now run build and tell me if it compiles.
Building project (Development)
UnrealBuildTool — compiling 4 modified files…
Enter to send · Shift+Enter for newline · @ to attach