RecordAnimation

RecordAnimation

#Overview

name: RecordAnimation

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

It is referenced in 12 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of RecordAnimation is to capture and record animation data from a SkeletalMeshComponent in Unreal Engine 5. This functionality is primarily used in the animation editing and recording systems within the engine.

The RecordAnimation function is utilized by several Unreal Engine subsystems and modules, including:

  1. Persona: The animation editing tool in Unreal Engine
  2. SequenceRecorder: A module for recording animations and sequences
  3. MovieScene: The cinematics and sequencer system

The value of this variable is not set directly, as it’s a function rather than a variable. Instead, it’s called in various places to initiate the animation recording process.

This function interacts with several other components and variables, such as:

  1. FAnimationRecordingSettings: Contains settings for the animation recording process
  2. USkeletalMeshComponent: The component from which the animation is recorded
  3. UAnimSequence: The target animation sequence where the recorded data is stored

Developers should be aware of the following when using RecordAnimation:

  1. It can be called with different parameter combinations, allowing for flexibility in how animations are recorded.
  2. The function is used in both editor tools (like Persona) and runtime recording scenarios.
  3. It’s often used in conjunction with other animation-related functions like StopRecordingAnimation.

Best practices when using RecordAnimation include:

  1. Ensure the SkeletalMeshComponent is valid before attempting to record.
  2. Use appropriate FAnimationRecordingSettings to control the recording process.
  3. Handle the return value to check if the recording started successfully.
  4. Pair RecordAnimation calls with corresponding StopRecordingAnimation calls to manage the recording state properly.
  5. Be mindful of performance implications when recording animations, especially in runtime scenarios.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/Persona/Private/AnimTimeline/SAnimTimelineTransportControls.cpp:210

Scope (from outer to inner):

file
function     FReply SAnimTimelineTransportControls::OnClick_Record

Source code excerpt:

FReply SAnimTimelineTransportControls::OnClick_Record()
{
	StaticCastSharedRef<FAnimationEditorPreviewScene>(GetPreviewScene())->RecordAnimation();

	return FReply::Handled();
}

bool SAnimTimelineTransportControls::IsLoopStatusOn() const
{

#Loc: <Workspace>/Engine/Source/Editor/Persona/Private/AnimationEditorPreviewScene.cpp:978

Scope (from outer to inner):

file
function     void FAnimationEditorPreviewScene::RecordAnimation

Source code excerpt:

}

void FAnimationEditorPreviewScene::RecordAnimation()
{
	bool bInRecording = false;
	FPersonaModule& PersonaModule = FModuleManager::GetModuleChecked<FPersonaModule>(TEXT("Persona"));
	PersonaModule.OnIsRecordingActive().ExecuteIfBound(SkeletalMeshComponent, bInRecording);

	if (bInRecording)

#Loc: <Workspace>/Engine/Source/Editor/Persona/Private/AnimationEditorPreviewScene.h:266

Scope (from outer to inner):

file
class        class FAnimationEditorPreviewScene : public IPersonaPreviewScene, public FEditorUndoClient

Source code excerpt:


	/** Begin recording animation form the preview component **/
	void RecordAnimation();

	/** Check whether recording of the preview component is available */
	bool IsRecordAvailable() const;

	/** Get a status image to display for recording in progress */
	FSlateIcon GetRecordStatusImage() const;

#Loc: <Workspace>/Engine/Source/Editor/Persona/Private/SAnimationScrubPanel.cpp:233

Scope (from outer to inner):

file
function     FReply SAnimationScrubPanel::OnClick_Record

Source code excerpt:

FReply SAnimationScrubPanel::OnClick_Record()
{
	StaticCastSharedRef<FAnimationEditorPreviewScene>(GetPreviewScene())->RecordAnimation();

	return FReply::Handled();
}

bool SAnimationScrubPanel::IsLoopStatusOn() const
{

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/AnimationRecorder.cpp:1243

Scope (from outer to inner):

file
function     bool FAnimationRecorderManager::RecordAnimation

Source code excerpt:



bool FAnimationRecorderManager::RecordAnimation(USkeletalMeshComponent* Component, const FString& AssetPath, const FString& AssetName, const FAnimationRecordingSettings& Settings)
{
	if (Component)
	{
		FAnimRecorderInstance NewInst;
		NewInst.Init(Component, AssetPath, AssetName, Settings);
		bool const bSuccess = NewInst.BeginRecording();

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/AnimationRecorder.cpp:1270

Scope (from outer to inner):

file
function     bool FAnimationRecorderManager::RecordAnimation

Source code excerpt:

}

bool FAnimationRecorderManager::RecordAnimation(USkeletalMeshComponent* Component, UAnimSequence* Sequence, const FAnimationRecordingSettings& Settings)
{
	if (Component)
	{
		FAnimRecorderInstance NewInst;
		NewInst.Init(Component, Sequence, nullptr, Settings);
		bool const bSuccess = NewInst.BeginRecording();

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/AnimationRecorder.cpp:1297

Scope (from outer to inner):

file
function     bool FAnimationRecorderManager::RecordAnimation

Source code excerpt:

}

bool FAnimationRecorderManager::RecordAnimation(USkeletalMeshComponent* Component, UAnimSequence* Sequence, FAnimationSerializer* InSerializer, const FAnimationRecordingSettings& Settings)
{
	if (Component)
	{
		FAnimRecorderInstance NewInst;
		NewInst.Init(Component, Sequence, InSerializer, Settings);
		bool const bSuccess = NewInst.BeginRecording();

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/Sections/MovieSceneAnimationSectionRecorder.cpp:105

Scope (from outer to inner):

file
function     void FMovieSceneAnimationSectionRecorder::CreateSection

Source code excerpt:

			if (AnimSequence.IsValid())
			{
				FAnimationRecorderManager::Get().RecordAnimation(SkeletalMeshComponent.Get(), AnimSequence.Get(), AnimationSettings);

				if (MovieScene)
				{
					UMovieSceneSkeletalAnimationTrack* AnimTrack = MovieScene->FindTrack<UMovieSceneSkeletalAnimationTrack>(Guid);
					if (!AnimTrack)
					{

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/SequenceRecorderModule.cpp:267

Scope (from outer to inner):

file
class        class FSequenceRecorderModule : public ISequenceRecorder, private FSelfRegisteringExec
function     virtual bool Exec_Editor

Source code excerpt:

	{
#if WITH_EDITOR
		if (FParse::Command(&Cmd, TEXT("RecordAnimation")))
		{
			return HandleRecordAnimationCommand(InWorld, Cmd, Ar);
		}
		else if (FParse::Command(&Cmd, TEXT("StopRecordingAnimation")))
		{
			return HandleStopRecordAnimationCommand(InWorld, Cmd, Ar);

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/SequenceRecorderModule.cpp:329

Scope (from outer to inner):

file
class        class FSequenceRecorderModule : public ISequenceRecorder, private FSelfRegisteringExec
function     static bool HandleRecordAnimationCommand

Source code excerpt:

				FParse::Token(Str, AssetPath, UE_ARRAY_COUNT(AssetPath), 0);
				FString const AssetName = FPackageName::GetLongPackageAssetName(AssetPath);
				return FAnimationRecorderManager::Get().RecordAnimation(SkelComp, AssetPath, AssetName, GetDefault<USequenceRecorderSettings>()->DefaultAnimationSettings);
			}
		}
#endif
		return false;
	}

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Private/SequenceRecorderModule.cpp:832

Scope (from outer to inner):

file
class        class FSequenceRecorderModule : public ISequenceRecorder, private FSelfRegisteringExec
function     static void HandlePersonaRecord

Source code excerpt:

	static void HandlePersonaRecord(USkeletalMeshComponent* Component)
	{
		FAnimationRecorderManager::Get().RecordAnimation(Component, FString(), FString(), GetDefault<USequenceRecorderSettings>()->DefaultAnimationSettings);
	}

	static void HandlePersonaStopRecording(USkeletalMeshComponent* Component)
	{
		FAnimationRecorderManager::Get().StopRecordingAnimation(Component);
	}

#Loc: <Workspace>/Engine/Source/Editor/SequenceRecorder/Public/AnimationRecorder.h:244

Scope: file

Source code excerpt:


	/** Starts recording an animation. */
	bool RecordAnimation(USkeletalMeshComponent* Component, const FString& AssetPath = FString(), const FString& AssetName = FString(), const FAnimationRecordingSettings& Settings = FAnimationRecordingSettings());

	bool RecordAnimation(USkeletalMeshComponent* Component, UAnimSequence* Sequence, const FAnimationRecordingSettings& Settings = FAnimationRecordingSettings());
	
	bool RecordAnimation(USkeletalMeshComponent* Component, UAnimSequence* Sequence, FAnimationSerializer *InAnimationSerializer,  const FAnimationRecordingSettings& Settings = FAnimationRecordingSettings());

	bool IsRecording(USkeletalMeshComponent* Component);

	bool IsRecording();

	UAnimSequence* GetCurrentlyRecordingSequence(USkeletalMeshComponent* Component);