# CommitMapChange actually not changing level

**URL:** <https://forums.unrealengine.com/t/commitmapchange-actually-not-changing-level/451294>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 26, 2019, 10:04am UTC](https://forums.unrealengine.com/t/commitmapchange-actually-not-changing-level/451294 "2019-06-26T10:04:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Marie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexandre\_Marie](https://forums.unrealengine.com/u/Alexandre_Marie)\
**Post date:** [June 26, 2019, 10:04am UTC](https://forums.unrealengine.com/t/commitmapchange-actually-not-changing-level/451294/1 "2019-06-26T10:04:54Z")

</div>

Hi everyone,

I’m facing a really strange problem,

I followed the tutorial in [https://answers.unrealengine.com/questions/46503/how-to-use-preparemapchangecommitmapchange.html#answer-320371](https://answers.unrealengine.com/questions/46503/how-to-use-preparemapchangecommitmapchange.html#answer-320371)

Everything seems right but when I call GetWorld()-\>CommitMapChange() it’s not switching at all and it not even reload the first level even if my TArray of FName levels is correctly set.

And for proof the PreCommitChange is called with the rights PreviousMapName and NextMapName.

Did I missed something ?

```
UAsyncLoader::UAsyncLoader()
{
	GetAllMapsDatas(Maps);
}

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

	GetWorld()->PrepareMapChange(levelsToLoad);

	GetWorld()->GetTimerManager().SetTimer(TimerLoading, this, &UAsyncLoader::IsLoadingReady, 0.5f, true);

}

void UAsyncLoader::IsLoadingReady()
{
	if (GetWorld()->IsMapChangeReady() && !IsAsyncLoading())
	{
		GetWorld()->GetTimerManager().ClearTimer(TimerLoading);
		OnMapLoded.Broadcast();
	}
}

void UAsyncLoader::LaunchMapTravel()
{
	GetWorld()->CommitMapChange();
	UKismetSystemLibrary::PrintString(GetWorld(), TEXT("Commit Map"), true, true, FLinearColor::Yellow, 10.f);
}

bool UAsyncLoader::GetAllMapsDatas(TArray<FAssetData>& mapsArray)
{
	// Create a library of UWorlds
	UObjectLibrary* objectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, true);

	// Loads all the maps from the given path inside the library
	objectLibrary->LoadAssetDataFromPath(TEXT("/Game/Maps"));

	// Get all the metadatas from the library
	objectLibrary->GetAssetDataList(mapsArray);

	//FString debug = "Found Maps = " + FString::FromInt(mapDatas.Num());
	//UKismetSystemLibrary::PrintString(GetWorld(), *debug, true, true, FLinearColor::Yellow, 10.f);

	if (mapsArray.Num() > 0)
	{
		return true;
	}

	return false;

}

```

And when the OnMapLoaded is triggered it enables a button to actually launch the commit. When I click it the PreCommitMapCHange is called with the right arguments and PostCommitChange is fired then but when I do GetWorld()-\>GetFullName() I’m still on the same level.

Best regards,

Alexandre
