diff --git a/Content/Blueprints/Pawns/BP_PawnTank.uasset b/Content/Blueprints/Pawns/BP_PawnTank.uasset index 3f56fc5..4fb7611 100644 --- a/Content/Blueprints/Pawns/BP_PawnTank.uasset +++ b/Content/Blueprints/Pawns/BP_PawnTank.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0dfa34e9e710dc948138b99e70d57b70248d6a9642112f216f9b31a96472416b -size 38048 +oid sha256:fdab66de9b566c666f7ac0675896b3c110c30739362f50ab8e34550b95f66603 +size 39271 diff --git a/Content/Blueprints/Pawns/BP_PawnTurret.uasset b/Content/Blueprints/Pawns/BP_PawnTurret.uasset index fbfa3f3..fb98235 100644 --- a/Content/Blueprints/Pawns/BP_PawnTurret.uasset +++ b/Content/Blueprints/Pawns/BP_PawnTurret.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6f5bce080339c33c0e9254163b22818b5a2eb8bf0130121a0af213d7412253f -size 34083 +oid sha256:5da67c5292915394a513be1aa9472b90c71ada3b72d74077474f0fb4a5bc7a07 +size 35174 diff --git a/Source/ToonTanks/HealthComponent.cpp b/Source/ToonTanks/HealthComponent.cpp new file mode 100644 index 0000000..3b93742 --- /dev/null +++ b/Source/ToonTanks/HealthComponent.cpp @@ -0,0 +1,37 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "HealthComponent.h" + +// Sets default values for this component's properties +UHealthComponent::UHealthComponent() +{ + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features + // off to improve performance if you don't need them. + PrimaryComponentTick.bCanEverTick = true; + + // ... +} + + +// Called when the game starts +void UHealthComponent::BeginPlay() +{ + Super::BeginPlay(); + Health = MaxHealth; + GetOwner()->OnTakeAnyDamage.AddDynamic(this, &UHealthComponent::DamageTaken); +} + + +// Called every frame +void UHealthComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + // ... +} + +void UHealthComponent::DamageTaken(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* Instigator, AActor* DamageCauser) +{ + UE_LOG(LogTemp, Warning, TEXT("Damage Taken")); +} diff --git a/Source/ToonTanks/HealthComponent.h b/Source/ToonTanks/HealthComponent.h new file mode 100644 index 0000000..7a2d980 --- /dev/null +++ b/Source/ToonTanks/HealthComponent.h @@ -0,0 +1,40 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "HealthComponent.generated.h" + + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class TOONTANKS_API UHealthComponent : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UHealthComponent(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +private: + // Default Max Health + UPROPERTY(EditAnywhere) + float MaxHealth = 100.0f; + + // Current Health Value + float Health = 0.0f; + + // Function for Damage Event + UFUNCTION() + void DamageTaken(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* Instigator, AActor* DamageCauser); + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + +};