Download

Level Sequence actor rebinding in C++

Hey guys. In my game, enemies are spawned into the level with Spawner Actors rather than placed directly in the scene. I’m now trying to implement a “boss fight”, where a cutscene/LevelSequence featuring the boss and a couple of other regular enemies plays, and it transitions directly back into gameplay.

In my attempt to accomplish this, I’ve made a “BossTriggerVolume” actor. This BossTriggerVolume has a reference to the ULevelSequence, and to the Spawner from which the boss and its minions should be spawned. In its NotifyActorBeginOverlap method, when the player enters, it tells the Spawner to spawn its character, receives a reference to the spawned character via a dispatched event, and then starts the cutscene. The code looks something like this:



if (Spawner != nullptr)
{ 
    //ABossTriggerVolume::OnSpawnCharacter adds each spawned character to a SpawnedCharacters TArray
    Spawner->OnSpawnedCharacter.AddDynamic(this, &ABossTriggerVolume::OnSpawnCharacter);
    Spawner->SpawnCharacters();
}
if (OpeningCutsceneToPlay != nullptr)
{     
    FMovieSceneSequencePlaybackSettings PlaybackSettings; 

    ULevelSequencePlayer* LevelSequencePlayer = ULevelSequencePlayer::CreateLevelSequencePlayer(
        GetWorld(), 
        OpeningCutsceneToPlay, 
        PlaybackSettings, 
        LevelSequenceActor
    ); 
     //This is where I'd like to rebind the characters in my SpawnedCharacters TArray (which now contains the boss and other enemies) to my LevelSequence's Spawnables

    LevelSequencePlayer->Play(); 
}


So currently, I walk through the trigger and the cutscene plays and the boss/enemies are spawned, but I’d like to replace the LevelSequence stand-in Spawnables with the characters in the SpawnedCharacters array.

I’ve been referencing this doc, which is written for for Blueprints, but as always I’m having trouble figuring out the C++ analogue for functionality that is apparently easy-peasy in Blueprints. ALevelSequenceActor contains a method called SetBinding which takes an FMovieSceneObjectBindingId object that I have no idea from where I’m supposed to get. My LevelSequence has a Spawnable Actor track called “BossStandin” which is where I’d like to slot in my boss character, but where Blueprints has a GetSequenceBinding node which provides a handy dropdown of the tracks, I’m not sure exactly what I’m supposed to do in C++. Needless to say, I’m the first person in the history of mankind who wants to replace a LevelSequence Actor binding using C++ instead of Blueprints, so I’ve had no luck figuring it out from Google.

Any insight would be greatly appreciated! Worst case scenario, I can just set this up in Blueprints and make the adjustments needed for my game to process world-placed characters properly.

Hello !
Have you figured out the solution?