Download

Handle Sequencer Events in C++ code

Hi all!

Is it possible to handle events from Level Sequence in C++ code? I have found this article:

But it’s only for blueprints :frowning:

Hope for your help.

BTW One more question :slight_smile: Is it possible to loop one Shot in Level Sequence? Can’t find this feature…

Okey, I found the solution. The main idea in this article “Solus C++ Tutorial: Creating Custom Level Blueprints in C++”:

First of all create own LevelScriptActor based on ALevelScriptActor. And realize in its all necessary events. For example:


UCLASS()
class SOMEGAME_API ADefaultLevelScriptActor : public ALevelScriptActor
{
    GENERATED_BODY()
	
public:	
	
    UFUNCTION(BlueprintCallable, Category = "Level Sequence")
    void OnFadeFinished() { /* Some code here */ }
};

Then reparent Level Blueprint to our class. And add event called “OnFadeFinished” to our Level Sequence.

That is all and all works fine :o

Its already been a while but i think this is important as i did my fair share of digging too and this popped up a lot of times.

The problem with your event only firing when it doesnt hold any parameters comes from the fact that Unreal doesnt pass the struct holding the variables to the event but each variable separately.
So in case your struct holds a string and an integer the target blueprint event has to have separate inputs for each of those and not only one for the complete struct.

This is also mentioned in this post: Sequencer: Is it possible to pass struct as parameter to custom events? - UE4 AnswerHub

Further more in the following forum post is described how to create custom event structs and how to add them to a track in c++: [Solved] Create sequencer events from C++ in 4.20 - C++ Gameplay Programming - Unreal Engine Forums