#[Resolved] Cooldown countdown broken on server when getting countdown time from gamemode

3 messages · Page 1 of 1 (latest)

plush raft
#

In the 'Cooldown Announcement' video' around 09:15, there's a change in Player Controller to get the Countdown Time from Gamemode directly if having authority.

Adding that code did break the cooldown countdown on my server player - it just is stuck at the start value and does not change, while on clients, countdown works.

uint32 SecondsLeft = FMath::CeilToInt(TimeLeft);

// no countdown on server player if getting Countdown Time from Gamemode directly
if (HasAuthority())    // on server, get seconds left directly from game mode - avoid being off
{
    BlasterGameMode = BlasterGameMode == nullptr ? Cast<ABlasterGameMode>(UGameplayStatics::GetGameMode(this)) : BlasterGameMode;
    if (BlasterGameMode)
    {
        SecondsLeft = FMath::CeilToInt(BlasterGameMode->GetCountdownTime() + LevelStartingTime);
    }
}```

The solution is simple: in GameMode Tick(), the Update of CountdownTime when in Cooldown state was simply missing.

```c++
void ABlasterGameMode::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    if (bDelayedStart && MatchState == MatchState::WaitingToStart)
    {
        //blabla
    }
    else if (MatchState == MatchState::InProgress)
    {
        //blabla
    }
    // === FIX === need to update CountdownTime when getting directly  
    else if (MatchState == MatchState::Cooldown)
    {
        CountdownTime = CooldownTime + WarmupTime + MatchTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
    }

}```

I rechecked both videos, 'Custom Match States' and 'Cooldown Announcement' - but that part is not in there - also not in the github commits for the lectures, so it looks like a little bug in the course. Maybe I'm missing something else, but it would be great if Stephen could have a look at this.
plush raft
#

Ah, getting to the next chapter, I see that this code is added. Well, a little comment in the videos would be great to keep the timeline of the course consistent, otherwise students end up with problems just caused by inconsistencies. On the other hand, that's a good learning effect. Great course, having a lot of fun with this 👍

quaint plume
#

Great that you solved it
Yes there are a few places that - can - be a snag so to ride along with it is a good idea, i think most of the "blanks" have been revisited either here on Discord or at Udemy so it should be a reasonably smooth ride.
I mark this as Resolved
Cheers