How to do it...

  1. Inside your AParamDelegateListener::BeginPlay function, change the call to BindUObject to the following:
// Called when the game starts or when spawned
void AParamDelegateListener::BeginPlay()
{
Super::BeginPlay();

UWorld* TheWorld = GetWorld();

if (TheWorld != nullptr)
{
AGameModeBase* GameMode =
UGameplayStatics::GetGameMode(TheWorld);

AChapter_05GameModeBase * MyGameMode =
Cast<AChapter_05GameModeBase>
(GameMode);

if (MyGameMode != nullptr)
{
MyGameMode->MyParameterDelegate.BindUObject(this,
&AParamDelegateListener::SetLightColor,
false
);
}
}

}
  1. In the ParamDelegateListener.h file, change the declaration of SetLightColor to the following:
UCLASS()
class CHAPTER_05_API AParamDelegateListener : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor's properties
AParamDelegateListener();

UFUNCTION()
void SetLightColor(FLinearColor LightColor, bool EnableLight);

UPROPERTY()
UPointLightComponent* PointLight;

protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;

public:
// Called every frame
virtual void Tick(float DeltaTime) override;

};

  1. Alter the implementation of SetLightColor, as follows:
void AParamDelegateListener::SetLightColor(FLinearColor LightColor, bool EnableLight)
{
PointLight->SetLightColor(LightColor);
PointLight->SetVisibility(EnableLight);
}
  1. Compile and run your project. Verify that, when you walk into TriggerVolume, the light turns off because of the false payload parameter that was passed in when you bound the function.