IncrementEXP when player overlaps
This commit is contained in:
parent
7f6e41cb50
commit
cafb8206e5
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "EXPPickup.h"
|
||||
|
||||
#include "PlayerCharacter.h"
|
||||
|
||||
void AEXPPickup::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
@ -16,7 +18,9 @@ void AEXPPickup::Tick(float DeltaSeconds)
|
|||
void AEXPPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
{
|
||||
// TODO: Add EXP to player EXP component
|
||||
|
||||
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||
if (APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(OtherActor))
|
||||
{
|
||||
PlayerCharacter->GetEXPComponent()->IncrementEXP(EXP);
|
||||
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,10 @@ UCLASS()
|
|||
class VAMPIRES_API AEXPPickup : public APickup
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
int EXP = 1;
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
@ -21,6 +24,6 @@ public:
|
|||
virtual void Tick(float DeltaSeconds) override;
|
||||
|
||||
virtual void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||
const FHitResult& SweepResult) override;
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||
const FHitResult& SweepResult) override;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue