156 - Health Pickup
After Width: | Height: | Size: 485 KiB |
After Width: | Height: | Size: 280 KiB |
After Width: | Height: | Size: 356 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 388 KiB |
After Width: | Height: | Size: 99 KiB |
After Width: | Height: | Size: 3.6 MiB |
After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 369 KiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 124 KiB |
After Width: | Height: | Size: 24 KiB |
|
@ -9,8 +9,6 @@
|
||||||
void AAmmoPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
void AAmmoPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
||||||
bool bFromSweep, const FHitResult& SweepResult)
|
bool bFromSweep, const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("AmmoPickup Overlap"));
|
|
||||||
|
|
||||||
Super::OnSphereOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
Super::OnSphereOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||||
|
|
||||||
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(OtherActor);
|
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(OtherActor);
|
||||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
||||||
int32 OtherBodyIndex,
|
int32 OtherBodyIndex,
|
||||||
bool bFromSweep,
|
bool bFromSweep,
|
||||||
const FHitResult& SweepResult
|
const FHitResult& SweepResult
|
||||||
);
|
) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "HealthPickup.h"
|
||||||
|
|
||||||
|
#include "NiagaraComponent.h"
|
||||||
|
#include "NiagaraFunctionLibrary.h"
|
||||||
|
#include "Blaster/Character/BlasterCharacter.h"
|
||||||
|
|
||||||
|
AHealthPickup::AHealthPickup()
|
||||||
|
{
|
||||||
|
bReplicates = true;
|
||||||
|
PickupEffectComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("PickupEffectComponent"));
|
||||||
|
PickupEffectComponent->SetupAttachment(RootComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AHealthPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
||||||
|
bool bFromSweep, const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
Super::OnSphereOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||||
|
|
||||||
|
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(OtherActor);
|
||||||
|
if (BlasterCharacter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AHealthPickup::Destroyed()
|
||||||
|
{
|
||||||
|
if (PickupEffect)
|
||||||
|
{
|
||||||
|
UNiagaraFunctionLibrary::SpawnSystemAtLocation(
|
||||||
|
this,
|
||||||
|
PickupEffect,
|
||||||
|
GetActorLocation(),
|
||||||
|
GetActorRotation()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Super::Destroyed();
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Pickup.h"
|
||||||
|
#include "HealthPickup.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class BLASTER_API AHealthPickup : public APickup
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
AHealthPickup();
|
||||||
|
virtual void Destroyed() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void OnSphereOverlap(
|
||||||
|
UPrimitiveComponent* OverlappedComponent,
|
||||||
|
AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp,
|
||||||
|
int32 OtherBodyIndex,
|
||||||
|
bool bFromSweep,
|
||||||
|
const FHitResult& SweepResult
|
||||||
|
) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float HealAmount = 100.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float HealingTime = 5.f;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
class UNiagaraComponent* PickupEffectComponent;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
class UNiagaraSystem* PickupEffect;
|
||||||
|
|
||||||
|
};
|
|
@ -44,7 +44,7 @@ void APickup::BeginPlay()
|
||||||
void APickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
void APickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
||||||
bool bFromSweep, const FHitResult& SweepResult)
|
bool bFromSweep, const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Pickup Overlap"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APickup::Tick(float DeltaTime)
|
void APickup::Tick(float DeltaTime)
|
||||||
|
|