Skip to content

AExperimentSpectatorController

Player controller used during demo playback to follow the subject and capture data.

Syntax

class AExperimentSpectatorController : public APlayerController

Remarks

During replay, a spectator controller is spawned to track the subject pawn, attach cameras, log per-frame experiment state, and save rendered frames to disk. Subclass this controller to add experiment-specific logging. UCLASS

Inheritance Hierarchy

APlayerController → AExperimentSpectatorController

Methods

Method Signature Description Blueprint
AExperimentSpectatorController AExperimentSpectatorController::AExperimentSpectatorController(const FObjectInitializer &objectInitializer) Constructor.
AddCamera void AExperimentSpectatorController::AddCamera(AExperimentFrameCaptureCamera *camera) Registers a camera with the capture pipeline, so it receives SetSaveFolder() and SaveNextFrame() calls.
AddExperimentState void AExperimentSpectatorController::AddExperimentState(ExperimentState *newState) Appends a the current state of the experiment from this current tick to log.
AttachCamera void AExperimentSpectatorController::AttachCamera(AExperimentFrameCaptureCamera *camera) Attaches a newly created camera.
BeginPlayingState void AExperimentSpectatorController::BeginPlayingState() override Called when the controller enters the playing state.
BindSetDisplayPointsDelegate void AExperimentSpectatorController::BindSetDisplayPointsDelegate(FSetDisplayPointsDelegate delegate) Binds the widget event that receives the points value. yes
BindSetDisplayTextColorDelegate void AExperimentSpectatorController::BindSetDisplayTextColorDelegate(FSetDisplayTextColorDelegate delegate) Binds the widget event that receives the prompt text color. yes
BindSetDisplayTextDelegate void AExperimentSpectatorController::BindSetDisplayTextDelegate(FSetDisplayTextDelegate delegate) Binds the widget event that receives the on-screen prompt text. yes
BindSetTimeRemainingDelegate void AExperimentSpectatorController::BindSetTimeRemainingDelegate(FSetTimeRemainingDelegate delegate) Binds the widget event that receives the time-remaining value. yes
CaptureCameras void AExperimentSpectatorController::CaptureCameras() Save camera outputs from the current frame.
ConfigureSemanticLabels virtual void AExperimentSpectatorController::ConfigureSemanticLabels() Override to fill semanticLabels, semanticTagLabels, and defaultSemanticLabel.
CreateCameras void AExperimentSpectatorController::CreateCameras() Creates the cameras listed in the settings file.
FindTaggedPlayerPawn APawn * AExperimentSpectatorController::FindTaggedPlayerPawn() Search for the subject pawn in all the actors in the world.
FixTimeStep void AExperimentSpectatorController::FixTimeStep(bool fix) Enables or disables fixed time-stepping.
GetAgents TArray< const UExperimentAgentComponent * > AExperimentSpectatorController::GetAgents() const Collects all registered agent components in the world.
GetDemoCurrentTime double AExperimentSpectatorController::GetDemoCurrentTime() const Returns the current playback time of the replay.
GetDemoNetDriver UDemoNetDriver * AExperimentSpectatorController::GetDemoNetDriver() const Returns the UDemoNetDriver driving the current replay playback.
GetDemoSubsystem UExperimentDemoSubsystem * AExperimentSpectatorController::GetDemoSubsystem() const Returns the UExperimentDemoSubsystem for this session.
GetFrameNumber int AExperimentSpectatorController::GetFrameNumber() const Returns the current replay frame number.
GetReferencePlayerState AExperimentSubjectState * AExperimentSpectatorController::GetReferencePlayerState() const Get the current state at this tick of the replicated player pawn. yes
IsStale bool AExperimentSpectatorController::IsStale() Returns whether the replay has finished and this instance should be cleaned up.
LogExperimentState void AExperimentSpectatorController::LogExperimentState() Captures the state from all registered agents on this current tick, then appends the snapshot to the internal log buffer.
PostActorCreated void AExperimentSpectatorController::PostActorCreated() override Called after the actor is created in the world.
SaveExperimentLog void AExperimentSpectatorController::SaveExperimentLog() Writes all accumulated per-frame experiment state to a log file on disk.
SetFrameCaptureFolder void AExperimentSpectatorController::SetFrameCaptureFolder(const FString &folder) Sets the folder where rendered frames will be written.
SetReferencePawn void AExperimentSpectatorController::SetReferencePawn(APawn *newReferencePawn) Sets the reference pawn to follow, i.e.
SpawnLoggerComponent void AExperimentSpectatorController::SpawnLoggerComponent() Spawns and configures the UExperimentLoggerComponent used to collect per-frame state.
Tick void AExperimentSpectatorController::Tick(float deltaTime) override All the framewise logic.
TrySetViewTargetToPlayer void AExperimentSpectatorController::TrySetViewTargetToPlayer() Attempts to set the view target to the replaying subject pawn.
~AExperimentSpectatorController AExperimentSpectatorController::~AExperimentSpectatorController() Destructor.

Properties

Property Type Description Blueprint
cameras TArray< AExperimentFrameCaptureCamera * > Array of cameras attached to this spectator.
captureFrames bool Are we writing frames from cameras to disk?
currentTime double Accumulated replay time in seconds.
defaultSemanticLabel uint8 Semantic label for actors that match no semanticLabels entry.
delay double Initial delay in seconds before frame capture begins, to allow the scene to settle.
demoNetDriver UDemoNetDriver * The UDemoNetDriver driving the current replay playback.
demoSubsystem UExperimentDemoSubsystem * Cached pointer to the demo subsystem.
experimentType EExperimentType Experiment type for this session, used during log serialization.
fps int Target frames per second for the replay time step.
frameNumber int Zero-based index of the frame currently being rendered.
frameStates TArray< ExperimentState * > Buffer of per-frame experiment state snapshots accumulated during playback.
levelReloadRequested bool True once the end-of-replay level reload has been requested, so it only runs once.
loggerComponent UExperimentLoggerComponent * Logger component responsible for per-frame state collection.
needReference bool True until the reference pawn has been located and locked as the view target.
playerAgentID uint32 Unique ID of the player agent component, used for log identification.
referencePawn APawn * The subject pawn being followed during replay.
referencePlayerState AExperimentSubjectState * The player state of the reference subject pawn.
replayHUD UUserWidget * The HUD widget created from replayHUDClass.
replayHUDClass TSubclassOf< UUserWidget > HUD widget class to show during replay.
semSegTagger USemSegTagger * Tagger that writes the semantic labels into the custom depth stencil.
semanticLabels TMap< TSubclassOf< AActor >, uint8 > Actor class to stencil label map for semantic segmentation.
semanticTagLabels TMap< FName, uint8 > Actor tag to stencil label map for semantic segmentation.
stopDemo bool True when the replay has finished and this controller should be destroyed.
timeStep double Fixed time step duration in seconds (1.0 / fps).
worldSettings AWorldSettings * World settings, used to fix the time step during replay.

Delegates

Delegate Type Description Blueprint
SetDisplayPointsDelegate FSetDisplayPointsDelegate Delegate fired to update the displayed points value during replay.
SetDisplayTextColorDelegate FSetDisplayTextColorDelegate Delegate fired to change the color of the on-screen text prompt during replay.
SetDisplayTextDelegate FSetDisplayTextDelegate Delegate fired to update the on-screen text prompt during replay.
SetTimeRemainingDelegate FSetTimeRemainingDelegate Delegate fired to update the displayed time-remaining value during replay.