Hey, -
I have done what you have said and I get an error message saying, class AMyFPSGameCharacter a nonstatic member reference must be relative to a specific object my code is down below.
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyFPSGame.h"
#include "playerPickup.h"
#include "MyFPSGameCharacter.h"
// Sets default values
AplayerPickup::AplayerPickup()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
trigger = CreateDefaultSubobject<USphereComponent>(TEXT("Trigger sphere"));
RootComponent = trigger;
trigger->SetHiddenInGame(false);
trigger->bGenerateOverlapEvents = true;
trigger->OnComponentBeginOverlap.AddDynamic(this, &AplayerPickup::pickupTrigger);
}
// Called when the game starts or when spawned
void AplayerPickup::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AplayerPickup::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
void AplayerPickup::pickupTrigger(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult) {
UE_LOG(LogTemp, Warning, TEXT("This trigger works"));
Destroy();
AMyFPSGameCharacter::incrementCounter(); // This line is giving me the error
}