How to use LoadPackageAsync

Hi everyone,

I’m trying to implement asynchronous map loading. And as @anonymous_user_afd92cec replied in : https://forums.unrealengine.com/development-discussion/c-gameplay-programming/47363-how-to-open-level-asynchronously-without-visible-after-load?76088-How-to-open-level-asynchronously-without-visible-after-load=

for the first comment :

Use LoadPackageAsync function for precaching map and then manually prevent it from garbage collecting (AddToRoot maybe), and then use regular UGameplayStatics::OpenLevel when needed, it will automatically find precached map with specified name.

Yeah, this is right way. You will need some kind of UMapPreloader that could load map package in background and keep reference to it. Then when it’s finished you could initiate seamless travel.

Problem is I’m calling LoadPackageAsync with the right argument, my delegate is called but here are my values :

This is what I’m doing :

void UAsyncLoader::StartPreLoadingMap(uint8 Index)
{
	UKismetSystemLibrary::PrintString(GetWorld(), *Maps[Index].PackageName.ToString(), true, true, FLinearColor::Yellow, 10.f);

	PackageToLoad = Maps[Index].PackageName.ToString();
	AsyncOperationUID = LoadPackageAsync(PackageToLoad, OnPackageLoadedDelegate, 0, EPackageFlags::PKG_ContainsMap);

}

My “PackageToLoad” is in the form “/Game/Maps/World2” so it’s the correct syntax.

What am I doing wrong ?

The only thing is I had to remake the “EAsyncLoadingResult::Type” enum used in the “FLoadPackageAsyncDelegate” in my class to make it delegate compatible (UENUM) otherwise it’s not compiling because you need a UFUNCTION to bind it to the FAsync…Delegate"

Best regards everyone,

Alex

Post is freaking old by I thought I mention that there is free asset on the marketplace now that is doing this: