RealDocs

AGameStateBase::GetPlayerStartTime

function Engine Blueprint Since 4.14
#include "GameFramework/GameStateBase.h"
Access: public Specifiers: virtualUFUNCTIONBlueprintCallableconst

Description

Returns the world time at which the given player started (or should be considered to have started). The base implementation returns 0; override to track per-player join or spawn timestamps.

Caveats & Gotchas

  • The default implementation returns `0.0f` — you must store and return the timestamp yourself in a subclass. Calling this on the base class is only useful as a virtual dispatch target.
  • This is called by systems that calculate elapsed play time (e.g. for score weighting). Returning an incorrect value will silently skew those calculations.

Signature

UFUNCTION(BlueprintCallable, Category=GameState)
ENGINE_API virtual float GetPlayerStartTime(AController* Controller) const

Parameters

Name Type Description Default
Controller AController* The controller whose start time should be returned.

Return Type

float

Example

Track per-player start time in a custom game state C++
float AMyGameState::GetPlayerStartTime(AController* Controller) const
{
    if (const float* Time = PlayerStartTimes.Find(Controller))
    {
        return *Time;
    }
    return Super::GetPlayerStartTime(Controller);
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.