Player Dies oof
This commit is contained in:
parent
0113c6c958
commit
620d480dc0
BIN
Content/Enemies/Small/BP_SmallEnemy.uasset
(Stored with Git LFS)
BIN
Content/Enemies/Small/BP_SmallEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemies/Small/BTT_Attack.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Enemies/Small/BTT_Attack.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Enemies/Small/BT_SmallEnemy.uasset
(Stored with Git LFS)
BIN
Content/Enemies/Small/BT_SmallEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
BIN
Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/PrototypeLevel.umap
(Stored with Git LFS)
BIN
Content/Levels/PrototypeLevel.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Monolith/UI/WBP_Died.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Monolith/UI/WBP_Died.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -46,6 +46,7 @@ void AMonolithCharacter::BeginPlay()
|
||||
// Call the base class
|
||||
Super::BeginPlay();
|
||||
|
||||
MaxHealth = Health;
|
||||
Mesh1P = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
|
||||
CharMove = Cast<UCharacterMovementComponent>(GetComponentByClass(UCharacterMovementComponent::StaticClass()));
|
||||
if (CharMove) WalkSpeed = CharMove->MaxWalkSpeed;
|
||||
@ -122,6 +123,19 @@ static void UpdateMoveState(FMoveState& MoveState, int Forwards, int Sideways)
|
||||
}
|
||||
}
|
||||
|
||||
void AMonolithCharacter::IncrementHealth(float amount)
|
||||
{
|
||||
Health += amount;
|
||||
if (Health > MaxHealth)
|
||||
{
|
||||
Health = MaxHealth;
|
||||
}
|
||||
else if (Health <= 0)
|
||||
{
|
||||
Died();
|
||||
}
|
||||
}
|
||||
|
||||
void AMonolithCharacter::Move(const FInputActionValue& Value)
|
||||
{
|
||||
// input is a Vector2D
|
||||
|
@ -58,6 +58,11 @@ class AMonolithCharacter : public ACharacter
|
||||
// Amount of impulse to add when dashing
|
||||
UPROPERTY(EditAnywhere, Category = "MoveState", meta=(AllowPrivateAccess = "true"))
|
||||
float DashImpulse = 600.f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Health", meta=(AllowPrivateAccess = "true"))
|
||||
float Health = 100.f;
|
||||
|
||||
float MaxHealth;
|
||||
|
||||
USkeletalMeshComponent* Mesh1P;
|
||||
UCharacterMovementComponent* CharMove;
|
||||
@ -70,6 +75,25 @@ protected:
|
||||
void BeginPlay();
|
||||
void Tick(float DeltaSeconds) override;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
float GetHealth()
|
||||
{
|
||||
return Health;
|
||||
}
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ResetHealth()
|
||||
{
|
||||
Health = MaxHealth;
|
||||
}
|
||||
|
||||
// Increase/Decrease health by this amount, will handle death
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void IncrementHealth(float amount);
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void Died();
|
||||
|
||||
/** Called for movement input */
|
||||
void Move(const FInputActionValue& Value);
|
||||
void StopMove();
|
||||
|
Loading…
Reference in New Issue
Block a user