I have a UCLASS() called ACheckpoint with the following UBoxComponent member:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Gameplay")
UBoxComponent* Trigger;
It is initialized in my class’s constructor like so:
Trigger = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("Trigger"));
Trigger->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
Trigger->SetBoxExtent(FVector::FVector(32.0f, 480.0f, 480.0f), true);
Trigger->OnComponentBeginOverlap.Add(&ACheckpoint::OnTriggerCheckpoint); // ERROR: Reference to type 'const TScriptDelegate<FWeakObjectPtr> could not bind to an rvalue of type 'void (Checkpoint::*)(class Actor *, class UPrimitiveComponent*, int32, bool, const FHitResult&
Trigger->bGenerateOverlapEvents = true; // Enabled by default
Trigger->AttachTo(RootComponent);
The same class also features a function called OnTriggerCheckpoint with the following signature:
UFUNCTION()
void OnTriggerCheckpoint(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
The OnTriggerCheckpoint method is implemented in the class’s .cpp file.
When attempting to compile my code, I get the following error on Trigger->OnComponentBeginOverlap.Add(&ACheckpoint::OnTriggerCheckpoint);
Reference to type 'const TScriptDelegate<FWeakObjectPtr> could not bind to an rvalue of type 'void (Checkpoint::*)(class Actor *, class UPrimitiveComponent*, int32, bool, const FHitResult&
What am I doing wrong here?