How can I notify the `GameMode` that the game has ended (the pawn has reached the goal)?

Hi!

I’m using Unreal 5.3.2.

I’m developing a single player game. I want to notify the GameMode that the game is over when the pawn arrives to the goal. To do it I’ve used a Delegate in Pawn class.

Header file:


DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGoalReached);

UCLASS()
class REVERSEENGINEERING_API ARSRobotPawn : public APawn
{
	GENERATED_BODY()

public:
	UPROPERTY(BlueprintCallable, BlueprintAssignable)
	FGoalReached OnGoalReached;

	ARSRobotPawn();

Code file:

void ARSRobotPawn::OnOverlapBegin(
	UPrimitiveComponent* OverlappedComponent,
	AActor* OtherActor,
	UPrimitiveComponent* OtherComp,
	int32 OtherBodyIndex,
	bool bFromSweep,
	const FHitResult& SweepResult)
{
	if (OtherActor->IsA(ARSGoalActor::StaticClass()))
	{
		UE_LOG(LogTemp, Log, TEXT("Overlap Detected"));
		if (OnGoalReached.IsBound())
		{
			OnGoalReached.Broadcast();
		}
	}
}

I need to bind this delegate to the game mode, but I don’t know where to do it. I don’t know when the pawn is spawned and on which method is available to bind the delegate. In PostLogin?

Maybe, the question could be: how can I notify the GameMode that the game has ended (the pawn has reached the goal)?

Or maybe, I can use GameState instead (but I have no idea about how to do it using GameState).

Thanks