106 - On Possess

This commit is contained in:
Bert 2022-05-08 21:16:19 +02:00
parent f7c84eee2f
commit e478e0d433
3 changed files with 14 additions and 0 deletions

View File

@ -168,4 +168,6 @@ public:
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; }
FORCEINLINE bool IsEliminated() const { return bEliminated; }
FORCEINLINE float GetHealth() const { return Health; }
FORCEINLINE float GetMaxHealth() const { return MaxHealth; }
};

View File

@ -3,6 +3,7 @@
#include "BlasterPlayerController.h"
#include "Blaster/Character/BlasterCharacter.h"
#include "Blaster/HUD/BlasterHUD.h"
#include "Blaster/HUD/CharacterOverlay.h"
#include "Components/ProgressBar.h"
@ -16,6 +17,16 @@ void ABlasterPlayerController::BeginPlay()
BlasterHUD = Cast<ABlasterHUD>(GetHUD());
}
void ABlasterPlayerController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
if (const ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(InPawn))
{
SetHUDHealth(BlasterCharacter->GetHealth(), BlasterCharacter->GetMaxHealth());
}
}
void ABlasterPlayerController::SetHUDHealth(float Health, float MaxHealth)
{
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;

View File

@ -17,6 +17,7 @@ class BLASTER_API ABlasterPlayerController : public APlayerController
public:
void SetHUDHealth(float Health, float MaxHealth);
virtual void OnPossess(APawn* InPawn) override;
protected: