Compare commits
No commits in common. "3d16edc013622db09ee644208a562b41fa33edfe" and "4da7802d0453413078a4d4b58f81afe1e80874f4" have entirely different histories.
3d16edc013
...
4da7802d04
BIN
Content/Blueprints/Actors/BP_Projectile.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Actors/BP_Projectile.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Pawns/BP_PawnTank.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Pawns/BP_PawnTank.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Pawns/BP_PawnTurret.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Pawns/BP_PawnTurret.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Maps/Main.umap
(Stored with Git LFS)
BIN
Content/Maps/Main.umap
(Stored with Git LFS)
Binary file not shown.
@ -1,37 +0,0 @@
|
|||||||
// 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"));
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
// 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;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
@ -15,14 +15,12 @@ AProjectile::AProjectile()
|
|||||||
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement"));
|
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement"));
|
||||||
ProjectileMovement->InitialSpeed = 400.0f;
|
ProjectileMovement->InitialSpeed = 400.0f;
|
||||||
ProjectileMovement->MaxSpeed = 1000.0f;
|
ProjectileMovement->MaxSpeed = 1000.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
void AProjectile::BeginPlay()
|
void AProjectile::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
ProjectileMesh->OnComponentHit.AddDynamic(this, &AProjectile::OnHit);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,10 +31,3 @@ void AProjectile::Tick(float DeltaTime)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("HitComp: %s, Other Actor: %s, Other Comp: %s"),
|
|
||||||
*HitComp->GetName(), *OtherActor->GetName(), *OtherComp->GetName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +31,4 @@ private:
|
|||||||
// Projectile Movement Component for Shooting
|
// Projectile Movement Component for Shooting
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess="true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess="true"))
|
||||||
class UProjectileMovementComponent* ProjectileMovement;
|
class UProjectileMovementComponent* ProjectileMovement;
|
||||||
|
|
||||||
// Function for Hit Event
|
|
||||||
UFUNCTION()
|
|
||||||
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user