C++ Sequencer Start/Stop Events

Hello there.

I was wondering if there is a C++ event that triggers whenever a cinematic sequence in a sequencer starts?

In Unrealscript, there used to be an event in Actor.uc that called InterpolationStarted() whenever a matinee began:

event simulated InterpolationStarted(SeqAct_Interp InterpAction, InterpGroupInst GroupInst);
event simulated InterpolationFinished(SeqAct_Interp InterpAction);

Is there something similar for C++? A C++ function that gets called whenever a sequencer/matinee starts / ends? And if so, is it in Actor.h or is it in some other .h file?

Thank you for any help! :slight_smile:

In Unreal Engine 4, with the introduction of the Sequencer (which replaces Matinee), the event system has also changed. The new system doesn’t directly have an InterpolationStarted event in C++ as it was in Unrealscript, but you can bind to delegate events provided by the Sequencer.

If you want to detect when a Sequencer starts or ends, you can use the MovieScene’s delegates. Specifically, UMovieSceneSequencePlayer class provides the following delegates:

OnPlay
OnStop
OnPause
To bind a function to these events, you’ll use:

cpp
Copy code
YourSequencePlayer->OnPlay.AddDynamic(this, &YourClass::YourFunction);
Here’s a more detailed example:

Header File (.h)
cpp
Copy code
UCLASS()
class YOURPROJECT_API AYourActor : public AActor
{
GENERATED_BODY()

public:
AYourActor();

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Cinematic")
ULevelSequencePlayer* YourSequencePlayer;  // Assuming you have a reference to your sequence player.

// Functions to be called when sequence starts or stops.
UFUNCTION()
void OnSequencePlay();
UFUNCTION()
void OnSequenceStop();

};
Source File (.cpp)
cpp
Copy code
include “YourActor.h”

AYourActor::AYourActor()
{
// Bind the events
if(YourSequencePlayer)
{
YourSequencePlayer->OnPlay.AddDynamic(this, &AYourActor::OnSequencePlay);
YourSequencePlayer->OnStop.AddDynamic(this, &AYourActor::OnSequenceStop);
}
}

void AYourActor::OnSequencePlay()
{
UE_LOG(LogTemp, Warning, TEXT(“Sequence Started!”));
}

void AYourActor::OnSequenceStop()
{
UE_LOG(LogTemp, Warning, TEXT(“Sequence Stopped!”));
}
Make sure to replace YOURPROJECT, YourActor, and other placeholders with the appropriate names from your project.

This is a basic example, and there’s more you can do depending on your specific needs. Also, if you’re manipulating sequences or sequence players during runtime, you might need to adjust where and when you bind these events.

Finally, always ensure that the SequencePlayer is valid (i.e., not null) before trying to bind events or call functions on it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.