Sequencer.SecondsPerFrame

Sequencer.SecondsPerFrame

#Overview

name: Sequencer.SecondsPerFrame

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Sequencer.SecondsPerFrame is to control the playback speed in the Unreal Engine Sequencer when using the “Play Every Frame” mode. This setting variable is primarily used for debugging and testing purposes within the animation and cinematics system of Unreal Engine.

This setting variable is mainly relied upon by the MovieScene module, which is a core part of Unreal Engine’s Sequencer system. The Sequencer is used for creating and editing cinematic sequences and animations within the engine.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1.0 second per frame, but can be changed at runtime through console commands or programmatically.

The associated variable CVarSequencerSecondsPerFrame interacts directly with Sequencer.SecondsPerFrame. They share the same value and purpose, with CVarSequencerSecondsPerFrame being the actual console variable implementation.

Developers must be aware that this variable is specifically for use in the “Play Every Frame” mode, which is a debugging tool. It doesn’t honor world or actor pause states, time dilation, and will cause audio to be out of sync. It’s not intended for normal playback or production use.

Best practices when using this variable include:

  1. Only use it for debugging purposes.
  2. Be aware that it will affect performance and timing of animations.
  3. Remember to reset it to its default value (1.0) after debugging to avoid unintended effects in other parts of the project.
  4. Use it in conjunction with other Sequencer debugging tools for comprehensive testing.

Regarding the associated variable CVarSequencerSecondsPerFrame:

The purpose of CVarSequencerSecondsPerFrame is to provide a console-accessible way to control the Sequencer.SecondsPerFrame setting. It’s the actual implementation of the console variable that allows runtime modification of the setting.

This variable is used within the MovieScene module, specifically in the FMovieSceneTimeController class, which manages time-related functionality for the Sequencer.

The value of CVarSequencerSecondsPerFrame is set through the console variable system, allowing it to be changed via console commands or through code using the CVar API.

It directly interacts with and controls the behavior defined by Sequencer.SecondsPerFrame. When the value of CVarSequencerSecondsPerFrame is accessed (using GetFloat()), it determines how long each frame is held in the “Play Every Frame” mode.

Developers should be aware that changes to CVarSequencerSecondsPerFrame will immediately affect the “Play Every Frame” mode behavior. It’s a runtime-modifiable setting, which can be both powerful and potentially confusing if not managed carefully.

Best practices for using CVarSequencerSecondsPerFrame include:

  1. Use it for fine-tuning the “Play Every Frame” mode during debugging sessions.
  2. Document any non-default values used during development to ensure consistency across the team.
  3. Consider exposing it in a debug menu for easier access during testing.
  4. Always reset to the default value after debugging to prevent unexpected behavior in other parts of the project.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/MovieScene/Private/MovieSceneTimeController.cpp:14

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSequencerSecondsPerFrame(
	TEXT("Sequencer.SecondsPerFrame"),
	1.f,
	TEXT("Seconds per frame to wait when in play every frame mode."),
	ECVF_Default);

void FMovieSceneTimeController::Tick(float DeltaSeconds, float InPlayRate)
{

#Loc: <Workspace>/Engine/Source/Runtime/MovieScene/Public/MovieSceneFwd.h:75

Scope: file

Source code excerpt:

	Timecode,

	/** Debugging Tool: Hold on each whole frame for a Sequencer.SecondsPerFrame many wall-clock seconds before advancing to the next one. Does not honor world or actor pause state or time dilation and audio will be out of sync. */
	PlayEveryFrame,

	/** Custom clock source created and defined externally. */
	Custom,
};

#Associated Variable and Callsites

This variable is associated with another variable named CVarSequencerSecondsPerFrame. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/MovieScene/Private/MovieSceneTimeController.cpp:13

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<float> CVarSequencerSecondsPerFrame(
	TEXT("Sequencer.SecondsPerFrame"),
	1.f,
	TEXT("Seconds per frame to wait when in play every frame mode."),
	ECVF_Default);

void FMovieSceneTimeController::Tick(float DeltaSeconds, float InPlayRate)

#Loc: <Workspace>/Engine/Source/Runtime/MovieScene/Private/MovieSceneTimeController.cpp:222

Scope (from outer to inner):

file
function     FFrameTime FMovieSceneTimeController_PlayEveryFrame::OnRequestCurrentTime

Source code excerpt:

{
	double TimeDiff = FPlatformTime::Seconds() - PreviousPlatformTime;
	if (TimeDiff > CVarSequencerSecondsPerFrame->GetFloat())
	{
		// Update current time by moving onto the next frame
		FFrameRate CurrentDisplayRate = GetDisplayRate();
		FFrameTime OneDisplayFrame = CurrentDisplayRate.AsFrameTime(CurrentDisplayRate.AsInterval());
		CurrentTime = CurrentTime + ConvertFrameTime(OneDisplayFrame, CurrentDisplayRate, InCurrentTime.Rate);
		PreviousPlatformTime = FPlatformTime::Seconds();