[SOLVED][4.18]Binding to FOnMovieSceneSequencePlayerEvent OnFinished from C++

Hi. I just updated time ago to 4.18, and not remember from what version. But I had this line of code on my project and worked:

FadeOut->SequencePlayer->OnSequenceUpdated().AddUObject(this, &AVRViewController::FadeOutSequencePlayerUpdate);

FadeOut is ALevelSequencePlayer pointer from AVRViewController class, and it is retrieved from an existing actor in the scene. Before play the sequence, I want to bind to a callback member method. I’ve tried this:

FadeOut->SequencePlayer->OnFinished.AddUObject(this, &AVRViewController::FadeOutSequencePlayerUpdate);

But it says that AddUObject is not defined for FOnMovieSceneSequencePlayerEvent.

Can some body hint me in the right direction?

Thanks in advance.


I solved my own problem. I leave the explanation here for others.

In the code where I launched the animations, had a line like this:

FadeOut->SequencePlayer->OnSequenceUpdated().AddUObject(this, &AVRViewController::FadeOutSequencePlayerUpdate);

This is one of the signatures of adding an event handler **UObject **method to a delegate, like OnSequenceUpdated, because it was declared with the macro DECLARE_EVENT_ThreeParams that used the macro FUNC_DECLARE_EVENT that declares a subclass of **TBaseMulticastDelegate **templated class that has the method *AddUObject *amongst others.

But as every time the event handler was called, the sequence was not in a finished state, so normally did not call to the next step. I then saw an event that seems to be called exactly when the player of the sequence has finished normally, without being stopped.

This event is called *OnFinished *and if of type **FOnMovieSceneSequencePlayerEvent **that is declared using the macro DECLARE_DYNAMIC_MULTICAST_DELEGATE, that in turns uses FUNC_DECLARE_DYNAMIC_MULTICAST_DELEGATE macro that declares a subclass of **TBaseDynamicMulticastDelegate **template class, that inherits from **TMulticastScriptDelegate **template class. This class has a function Add, that needs as argument a reference of an object of type TScriptDelegate, that is a template class that you can use with the function BindUFunction, where you pass an **UObject **pointer, and the Name of a function to bind to, but that function name must be an **FName **(a Unreal Engine string), and for that to work, your class member function must be defined as an UFUNCTION to work, if not it will not be called.

So to make it work I rewrote the first code like this:

FScriptDelegate funcDelegate;
funcDelegate.BindUFunction(this, "FadeOutSequencePlayerUpdate");

The function FadeOutSequencePlayerUpdate is declared in the header this way:

void FadeOutSequencePlayerUpdate();

Hope that this could help others.