LoadStreamLevel ignores LatentActionInfo

I’m looking a way to call my method after level loading, but looks like the UGameplayStatics::LoadStreamLevel() method ignores my LatentActionInfo.

For example, I have “MovePlayerToLocation” method, which calls level loading:

void UMyGameInstance::MovePlayerToLocation()
{
    FLatentActionInfo ActionInfo = FLatentActionInfo();
    ActionInfo.CallbackTarget = this;
    ActionInfo.ExecutionFunction = FName("MovePlayer");
    ActionInfo.UUID = 123456;
    
    UGameplayStatics::LoadStreamLevel(this, FName("level name"), true, true, ActionInfo);
}

In the same class I have “MovePlayer” method, which I want to call after a new level will be loaded:

void UMyGameInstance::MovePlayer()
{
    UE_LOG(MainLog,Warning, TEXT("MovePlayer!!!"));
}

It loads a level, but doesn’t trigger this “MovePlayer” method.

I can’t find any examples of this LatentActionInfo usage. Looks like it’s used from Blueprint, but how to do this in C++?

Is MovePlayer a UFUNCTION?

Yes, both of them are UFUNCTION, but I don’t specify any additional parameters inside UFUNCTION() block. Should I add something specific in it?

I’m unsure, just checking since functions referenced by name generally have to be UFUNCTIONS. However FLatentActionInfo seems to be very poorly documented. I wasn’t able to figure it out. Maybe something to do with UUID not being set. FLatentActionInfo seems to be related to FLatentActionManager which can be retrieved through UWorld::GetLatentActionManager. Honestly, I’m out of ideas. Good luck! :stuck_out_tongue:

1 Like

I found solution! For some reason I missed ActionInfo.Linkage property. I’m not actually sure what does “The resume point within the function to execute” mean, but it works just with 0 as value. So solution is to add the next line into MovePlayerToLocation method:

ActionInfo.Linkage = 0;