When I created the timer in game mode, I bound it.
void AToonTankGameMode::HandleGameStart()
{
Tank = Cast<ATank>(UGameplayStatics::GetPlayerPawn(this, 0));
ToonTanksPlayerController = Cast<AToonTanksPlayerController>(UGameplayStatics::GetPlayerController(this, 0));
if (ToonTanksPlayerController)
{
ToonTanksPlayerController->SetPlayerEnabledState(false);
FTimerHandle PlayerEnableTimerHandle;
FTimerDelegate PlayerEnabledTimerDelegate = FTimerDelegate::CreateUObject(
ToonTanksPlayerController,
&AToonTanksPlayerController::SetPlayerEnabledState,
true
);
GetWorldTimerManager().SetTimer(
PlayerEnableTimerHandle,
PlayerEnabledTimerDelegate,
StartDelay,
false
);
}
}
But when I used SetTimer in Tower, I don’t think I bound it.
void ATower::BeginPlay()
{
Super::BeginPlay();
Tank = Cast<ATank>(UGameplayStatics::GetPlayerPawn(this, 0));
GetWorldTimerManager().SetTimer(FireRateTimerHandle, this, &ATower::CheckFireCondition, FireRate, true);
}
I do binding in game mode, but don’t I do binding in Tower?