IncrementGold when Player overlaps
This commit is contained in:
parent
2d078ec48c
commit
7f6e41cb50
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include "GoldPickup.h"
|
#include "GoldPickup.h"
|
||||||
|
|
||||||
|
#include "PlayerCharacter.h"
|
||||||
|
|
||||||
|
class APlayerCharacter;
|
||||||
|
|
||||||
void AGoldPickup::BeginPlay()
|
void AGoldPickup::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
@ -16,7 +20,9 @@ void AGoldPickup::Tick(float DeltaSeconds)
|
||||||
void AGoldPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
void AGoldPickup::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 Gold to player Gold component
|
if (APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(OtherActor))
|
||||||
|
{
|
||||||
|
PlayerCharacter->GetGoldComponent()->IncrementGold(Gold);
|
||||||
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ class VAMPIRES_API AGoldPickup : public APickup
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
int Gold = 1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue