IncrementEXP when player overlaps

This commit is contained in:
baz 2024-06-24 21:42:44 +01:00
parent 7f6e41cb50
commit cafb8206e5
2 changed files with 13 additions and 6 deletions

View File

@ -3,6 +3,8 @@
#include "EXPPickup.h" #include "EXPPickup.h"
#include "PlayerCharacter.h"
void AEXPPickup::BeginPlay() void AEXPPickup::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
@ -16,7 +18,9 @@ void AEXPPickup::Tick(float DeltaSeconds)
void AEXPPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, void AEXPPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{ {
// TODO: Add EXP to player EXP component if (APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(OtherActor))
{
PlayerCharacter->GetEXPComponent()->IncrementEXP(EXP);
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
} }
}

View File

@ -14,6 +14,9 @@ class VAMPIRES_API AEXPPickup : public APickup
{ {
GENERATED_BODY() GENERATED_BODY()
public:
int EXP = 1;
protected: protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;