106 - On Possess
This commit is contained in:
parent
f7c84eee2f
commit
e478e0d433
|
@ -168,4 +168,6 @@ public:
|
||||||
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
||||||
FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; }
|
FORCEINLINE bool ShouldRotateRootBone() const { return bRotateRootBone; }
|
||||||
FORCEINLINE bool IsEliminated() const { return bEliminated; }
|
FORCEINLINE bool IsEliminated() const { return bEliminated; }
|
||||||
|
FORCEINLINE float GetHealth() const { return Health; }
|
||||||
|
FORCEINLINE float GetMaxHealth() const { return MaxHealth; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "BlasterPlayerController.h"
|
#include "BlasterPlayerController.h"
|
||||||
|
|
||||||
|
#include "Blaster/Character/BlasterCharacter.h"
|
||||||
#include "Blaster/HUD/BlasterHUD.h"
|
#include "Blaster/HUD/BlasterHUD.h"
|
||||||
#include "Blaster/HUD/CharacterOverlay.h"
|
#include "Blaster/HUD/CharacterOverlay.h"
|
||||||
#include "Components/ProgressBar.h"
|
#include "Components/ProgressBar.h"
|
||||||
|
@ -16,6 +17,16 @@ void ABlasterPlayerController::BeginPlay()
|
||||||
BlasterHUD = Cast<ABlasterHUD>(GetHUD());
|
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)
|
void ABlasterPlayerController::SetHUDHealth(float Health, float MaxHealth)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
|
|
|
@ -17,6 +17,7 @@ class BLASTER_API ABlasterPlayerController : public APlayerController
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void SetHUDHealth(float Health, float MaxHealth);
|
void SetHUDHealth(float Health, float MaxHealth);
|
||||||
|
virtual void OnPossess(APawn* InPawn) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue