I’m making a pickup class, and when the player picks up the pickup, I want to increment a variable score. Where should I define this variable, and how do I increment it when the player picks it up?
Here is my function:
void APickup::TriggerEnter(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
UE_LOG(LogTemp, Warning, TEXT("The point has been picked up."));
PickupMesh->DestroyComponent();
// How do I increment my score variable?
}
I can’t define score in the pickup class, because then every instance of pickup will have its own score. I want one global score variable that is incremented when I pick my point up. I tried making a score variable in the character class, but I don’t know how to access it from the pickup class