RealDocs

APlayerState::SetStartTime

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public

Description

Overrides the StartTime property directly. Normally set automatically by the engine when a player joins; call this only when restoring state during seamless travel or custom serialisation.

Caveats & Gotchas

  • Does not trigger any callbacks or replication notifications — the underlying member is written directly. If clients need the updated value, it will propagate on the next replication update.
  • Passing a value that doesn't match world time will cause GetStartTime-based duration calculations to return incorrect results for the entire session.

Signature

ENGINE_API void SetStartTime(const int32 NewStartTime)

Parameters

Name Type Description Default
NewStartTime const int32 The new start time in integer seconds.

Return Type

void

Example

Restore start time after seamless travel C++
// Preserve original join time across level travels
void AMyGameMode::InitSeamlessTravelPlayer(AController* NewController)
{
    Super::InitSeamlessTravelPlayer(NewController);
    AMyPlayerState* PS = NewController->GetPlayerState<AMyPlayerState>();
    if (PS && SavedStartTime > 0)
    {
        PS->SetStartTime(SavedStartTime);
    }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.