blaster/Source/Blaster/Pickups/HealthPickup.cpp

45 lines
1.1 KiB
C++

// 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();
}