Skip to content

AMRISpectatorController

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

Syntax

class AMRISpectatorController : public APlayerController

Remarks

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

Inheritance Hierarchy

APlayerController → AMRISpectatorController

Methods

Method Signature Description Blueprint
AMRISpectatorController AMRISpectatorController::AMRISpectatorController(const FObjectInitializer &objectInitializer) Constructor.
AddExperimentState void AMRISpectatorController::AddExperimentState(MRIExperimentState *newState) Appends a the current state of the experiment from this current tick to log.
AddSensor void AMRISpectatorController::AddSensor(AMRIFrameCaptureCamera *sensor) Registers a frame-capture camera with the capture pipeline, so it receives SetSaveFolder() and SaveNextFrame() calls.
BeginPlayingState void AMRISpectatorController::BeginPlayingState() override Called when the controller enters the playing state.
CaptureSensors void AMRISpectatorController::CaptureSensors() Save sensor outputs from the current frame.
CreateSensors virtual void AMRISpectatorController::CreateSensors() Override point for creating frame-capture camera sensors.
FindTaggedPlayerPawn APawn * AMRISpectatorController::FindTaggedPlayerPawn() Search for the subject pawn in all the actors in the world.
FixTimeStep void AMRISpectatorController::FixTimeStep(bool fix) Enables or disables fixed time-stepping.
GetAgents TArray< const UMRIAgentComponent * > AMRISpectatorController::GetAgents() const Collects all registered agent components in the world.
GetDemoCurrentTime double AMRISpectatorController::GetDemoCurrentTime() const Returns the current playback time of the replay.
GetDemoNetDriver UDemoNetDriver * AMRISpectatorController::GetDemoNetDriver() const Returns the UDemoNetDriver driving the current replay playback.
GetDemoSubsystem UMRIDemoSubsystem * AMRISpectatorController::GetDemoSubsystem() const Returns the UMRIDemoSubsystem for this session.
GetFrameNumber int AMRISpectatorController::GetFrameNumber() const Returns the current replay frame number.
GetReferencePlayerState AMRISubjectState * AMRISpectatorController::GetReferencePlayerState() const Get the current state at this tick of the replicated player pawn.
IsStale bool AMRISpectatorController::IsStale() Returns whether the replay has finished and this instance should be cleaned up.
LogExperimentState void AMRISpectatorController::LogExperimentState() Captures the state from all registered agents on this current tick, then appends the snapshot to the internal log buffer.
PostActorCreated void AMRISpectatorController::PostActorCreated() override Called after the actor is created in the world.
SaveExperimentLog void AMRISpectatorController::SaveExperimentLog() Writes all accumulated per-frame experiment state to a log file on disk.
SetFrameCaptureFolder void AMRISpectatorController::SetFrameCaptureFolder(const FString &folder) Sets the folder where rendered frames will be written.
SetReferencePawn void AMRISpectatorController::SetReferencePawn(APawn *newReferencePawn) Sets the reference pawn to follow, i.e.
SpawnLoggerComponent void AMRISpectatorController::SpawnLoggerComponent() Spawns and configures the UMRILoggerComponent used to collect per-frame state.
Tick void AMRISpectatorController::Tick(float deltaTime) override All the framewise logic.
TrySetViewTargetToPlayer void AMRISpectatorController::TrySetViewTargetToPlayer() Attempts to set the view target to the replaying subject pawn.
~AMRISpectatorController AMRISpectatorController::~AMRISpectatorController() Destructor.

Properties

Property Type Description Blueprint
captureFrames bool Are we writing frames from sensors to disk?
currentTime double Accumulated replay time in seconds.
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 UMRIDemoSubsystem * 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< MRIExperimentState * > Buffer of per-frame experiment state snapshots accumulated during playback.
loggerComponent UMRILoggerComponent * 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 AMRISubjectState * The player state of the reference subject pawn.
sensors TArray< AMRIFrameCaptureCamera * > Array of frame-capture camera sensors attached to this spectator.
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.