Disable UnFreeze timer on PlayerController

Is there any way to temporarily disable the PlayerController’s UnFreeze timer on both client and server? For example if we are going to travel to another map we don’t want BeginInactiveState() to set TimerHandle_UnFreeze and later trigger UnFreeze().

Even if we try to manually clear this timer BeginInactiveState() will set it again. BeginInactiveState() is called whenever my player ServerTravels to a new map and then UnFreeze() will be called on both the client and the server after the player has loaded into the new map.

I want this functionally normally when the game is active but only want to disable in a case like when using seamless travel to reload the map.

BeginInactiveState() is virtual so you can override and add bool property to switch on/off this timer.

void AMyPlayerController::BeginInactiveState()
{
	if ( (GetPawn() != NULL) && (GetPawn()->Controller == this) )
	{
		GetPawn()->Controller = NULL;
	}
	SetPawn(NULL);

	if(bUnFreezeEnabled)
	{
		GetWorldTimerManager().SetTimer(TimerHandle_UnFreeze, this, &APlayerController::UnFreeze, GetMinRespawnDelay());
	}

}

Thanks for the answer. The only thing is, would the bool bUnFreezeEnabled have to be replicated in order for this to work properly? Based on my testing, BeginInactiveState() is executed on both the server and client for the same PlayerController. So both the server and client version of the PlayerController would have to know about changes to this bool.

It depends on how you want it to work.

[1] If bUnFreezeEnabled will not be replicated then the server and client can have different values in bUnFreezeEnabled

[2] If bUnFreezeEnabled will be replicated then when the server change value in bUnFreezeEnabled, the same value will be on the client side, but if the client change bUnFreezeEnabled, the change will only occur on this client. So there is still the possibility that the server and client will have different values in bUnFreezeEnabled.

[3] If bUnFreezeEnabled will be replicated and, for example, you will have a function:

void AMyPlayerController::UnFreezeEnabled(bool Value)
{
	if (Role == ROLE_Authority) // Only server can change bUnFreezeEnabled
	{
		bUnFreezeEnabled = Value;
	}
}

Then only the server has the ability to modify bUnFreezeEnabled, so the value will be the same on the server and on the client.

Remember to add the replicated properties to the following function:

void AMyPlayerController::GetLifetimeReplicatedProps( 
	TArray< FLifetimeProperty > & OutLifetimeProps 
) const 
{ 
 Super::GetLifetimeReplicatedProps(OutLifetimeProps);

 DOREPLIFETIME_CONDITION(AMyPlayerController, bUnFreezeEnabled, COND_OwnerOnly); 
}