I’m trying to make an Editor Utility Widget for helping to set keyframes on the control rig. I can get hold of the current Level Sequence, and can use, for example, ‘Set Local Control Rig Vector 2D’ to set the correct value, but it needs a frame to be specified.
I can’t seem to find any function for finding the current frame in the sequence. There are functions for getting start or end frames, but I just don’t see any way to get the current frame. Am I missing something?
Is this what your looking for?
currentFrame = unreal.LevelSequenceEditorBlueprintLibrary.get_current_time()
https://docs.unrealengine.com/5.0/en-US/PythonAPI/class/LevelSequenceEditorBlueprintLibrary.html
Thanks. I’d rather avoid Python if possible. It’s definitely possible in C++ but I guess not implemented in Blueprint.
Hey there @steve_kuva! If we’re trying to get the current level sequences current frame in blueprints, I think the only way is through this node, but I’ve never used/researched it before myself, so excellent question!
It’s part of Vcams themselves and that threw me off a bit.
In case the node did not work, you can use this snippet. I am using it in my plugin as well.
int32 GetCursorFrameNumber(ULevelSequence* LevelSequence)
{
auto toolKit = FToolkitManager::Get().FindEditorForAsset(LevelSequence);
if (toolKit)
{
IToolkit* toolKit_p = toolKit.Get();
if (auto levelSequenceEditorToolkit = static_cast<ILevelSequenceEditorToolkit*>(toolKit_p))
{
if (auto sequencer = levelSequenceEditorToolkit->GetSequencer())
{
return ConvertFrameTime(sequencer->GetGlobalTime().Time, sequencer->GetFocusedTickResolution(), sequencer->GetFocusedDisplayRate()).FloorToFrame().Value;
}
}
}
return -1;
}
It seems like that node has been removed in one of the more recent version of the plugin.
This didn’t work for me, as I couldn’t get the project to find ILevelSequenceEditorToolkit
. It seems like it’s an editor-only component, not sure if it would work in a build.
Here’s an alternative solution that takes a Level Sequence Actor:
#pragma once
#include "CoreMinimal.h"
#include "LevelSequenceActor.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "LevelSequenceExt.generated.h"
UCLASS()
class [PROJECT_API] ULevelSequenceExt : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
static float GetSequenceActorCurrentTime(const ALevelSequenceActor* SequenceActor);
};
#include "LevelSequenceExt.h"
float ULevelSequenceExt::GetSequenceActorCurrentTime(const ALevelSequenceActor* SequenceActor)
{
if (!IsValid(SequenceActor)) return -1;
const auto Player = SequenceActor->SequencePlayer;
FLevelSequencePlayerSnapshot Snapshot;
Player->TakeFrameSnapshot(Snapshot);
return Snapshot.MasterTime.AsSeconds();
}
I thought this node was awesome until I tried to render in movie render queue, turns out it doesn’t work when movie rendering, seems to work ok in runtime though when the sequencer is playing.
If anyone knows how to get it working in MRQ please let me know!
My work around is to create a variable called ‘frame’ and keyframe that in the sequencer, making sure it’s set to linear interpolation, after that you just add a keyframe value of ‘0’ at frame 0 and match the last keyframe value to the last frame number.
Weird, I’ve been using it in 5.4