First, I have to say, I’m not sure I’m posting this thread in the right place because I still not sure what is causing my issue. Since there is code involved, I thing this may be the best section for this.
So, my game have a few cutscenes that plays a movie .mp4 file (the movie is rendered in a UMG overlay) and then, after the movie reaches the end, a level sequence continues the cutscene, now in real time.
The problem is, there is a small gap between then: when the movie ends, I can see, for just a fraction of second, a frame with the wrong camera angle and the objects in the wrong position. It seems that there is a delay before the level sequence actually start.
This is the code that plays the movie:
MoviePlayer->OnEndReached.AddDynamic(this, &ACutscene::OnMovieEnded);
MoviePlayer->Play();
ShowMovieOnScreen(); // here the UMG widget is added to the viewport. I'm omitting this part because the implementation contains some blueprint code and events, but it is pretty straightforward
And here is the OnMovieEnded, called when the movie reaches the end:
void ACutscene::OnMovieEnded()
{
HideMovieOnScreen(); // Similar to ShowMovieOnScreen, but here the UMG widget is removed from the viewport
Sequence->SequencePlayer->Play();
}
Everything works almost fine, except this small delay before the sequence actually play.
My theory: there is no delay in the playback, and the delay is actually in the render thread. I think the UMG widget is being removed immediately, while the first frame of the level sequence will only be rendered after that small delay.
May my theory be correct? If so, what can I do to avoid this issue? I think a good idea would be to “prepare” the level sequence to put everything “in place” as soon the movie playback start - setup the camera’s transform and object’s transforms as they are expected in the first frame, enable the cinematic mode and stuff like that. But I don’t know if there is an easy way to do this (maybe a play() followed by a Pause() would be enough, but I’m afraid it can fire events and cause weird and unexpected behaviors).
If you have any idea that can fix this issue, I would be glad to hear, thank you.