I have some logic that I only want to execute once a level has finished loading, but I have two local variables that I need to use for it. So here is the code I have set up:
// “Exit” is a pointer to an actor and “RoomToLoad” is an FName.
auto AlignmentLambda = [&Exit, RoomToLoad] () → void
{
/* Logic… */
};// Loads the level with the name RoomToLoad currently is.
FLatentActionInfo LatentInfo;
UGameplayStatics::LoadStreamLevel(this, RoomToLoad, true, false, LatentInfo);// Try to bind AlignmentLambda to be called when OnLevelLoaded fires. Causes an error.
UGameplayStatics::GetStreamingLevel(this, RoomToLoad)->OnLevelLoaded.AddDynamic(this, AlignmentLambda);
But I’m getting an error with “OnLevelLoaded.AddDynamic.” I’m not super familiar with delegates, and there’s not much documentation on how OnLevelLoaded works, so I’m not sure where to go from here. Does anyone know how this is done?
Thanks in advance!