# UE5 Seamless travel bug found. We found the cause, and also have a workaround

**URL:** <https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, CPP\
**Created:** [June 16, 2022, 8:30pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652 "2022-06-16T20:30:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![liquid.mike](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/liquid.mike/32/88717_2.png) [@liquid.mike](https://forums.unrealengine.com/u/liquid.mike)\
**Post date:** [June 16, 2022, 8:30pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/1 "2022-06-16T20:30:26Z")

</div>

There is a bug that occurs in UE5 when seamless traveling that occurs if a client beats the server in loading the next level. There’s a race condition that causes the server to never see that client as having loaded the new level, therefore never transitions it’s player controller over to the new level, and the server and all the clients hang.

The following is for Epic. If you are interested in the workaround, it’s at the bottom

**Cause:**  
This seems due to an interaction with some state variables on PlayerController, and the methods:

```cpp
void APlayerController::ServerNotifyLoadedWorld_Implementation(FName WorldPackageName)

```

and

```cpp
void AGameModeBase::PostSeamlessTravel()

```

ServerNotifyLoadedWorld is an RPC that gets called from the client when they finish transitioning to a new level (either the transition map or the destination map)  
If the client calls this AFTER the server has loaded the map, all the checks in the code pass and GameMode::HandleSeamlessTravelPlayer is called and everything works fine.  
If the Server is STILL transitioning, this method is not called

So the clients who beat the server to the new level are in a sort of limbo state because the server is not ready to transition them. The server eventually loads the next level and calls GameMode::PostSeamlessTravel, which has the responsibility of transitioning all players who beat the server to the next level.

However, the way the server is detecting that the client beat the server is not correct. It does so by calling PlayerController::HasClientLoadedCurrentWorld, and here is where the issue lies. This method checks a number of things, but eventually this code executes:

```cpp
if (SeamlessTravelCount > 0)
{
	// In the case where seamless travel has occurred, make sure the client has actually completed the travel
	return bInCorrectWorld && (LastCompletedSeamlessTravelCount == SeamlessTravelCount);
}

```

This check fails:  
(LastCompletedSeamlessTravelCount == SeamlessTravelCount). In our testing, SeamlessTravelCount is incremented at the start of the seamless travel, however LastCompletedSeamlessTravelCount is not incremented until GameMode::HandleSeamlessTravelPlayer is called (which eventually calls APlayerController::PostSeamlessTravel(), which does the increment). So PlayerController::HasClientLoadedCurrentWorld never returns true because HandleSeamlessTravelPlayer is never called, and HandleSeamlessTravelPlayer is never called because HasClientLoadedCurrentWorld never returns true

**Workaround:**  
Subclass PlayerController if you have not already done so. add the following code to the header file:

```cpp
    virtual void NotifyLoadedWorld(FName WorldPackageName, bool bFinalDest) override;

    UFUNCTION(Reliable, Server, WithValidation, SealedEvent)
    void ServerNotifyLoadedWorldWorkaround(FName WorldPackageName);

```

And in the .cpp file add the following code:

```cpp
void AYourPlayerControllerName::NotifyLoadedWorld(FName WorldPackageName, bool bFinalDest)
{
    Super::NotifyLoadedWorld(WorldPackageName, bFinalDest);

    // Call custom ServerNotifyLoadedWorld
    ServerNotifyLoadedWorldWorkaround(WorldPackageName);
}

bool AYourPlayerControllerName::ServerNotifyLoadedWorld_Validate(FName WorldPackageName)
{
	RPC_VALIDATE( WorldPackageName.IsValid() );
	return true;
}

void AYourPlayerControllerName::ServerNotifyLoadedWorldWorkaround_Implementation(FName WorldPackageName)
{
    UE_LOG(LogPlayerController, Verbose, TEXT("AYourPlayerControllerName::ServerNotifyLoadedWorldWorkaround_Implementation: Client loaded %s"), *WorldPackageName.ToString());

    UWorld *CurWorld = GetWorld();

    // Only valid for calling, for PC's in the process of seamless traveling
    // NOTE: SeamlessTravelCount tracks client seamless travel, through the serverside gameplay code; this should not be replaced.
    if (CurWorld != NULL && !CurWorld->IsNetMode(NM_Client) && SeamlessTravelCount > 0 && LastCompletedSeamlessTravelCount < SeamlessTravelCount)
    {
        // Update our info on what world the client is in
        UNetConnection *const Connection = Cast<UNetConnection>(Player);

        if (Connection != NULL)
        {
            Connection->SetClientWorldPackageName(WorldPackageName);
        }

        // if both the server and this client have completed the transition, handle it
        FSeamlessTravelHandler &SeamlessTravelHandler = GEngine->SeamlessTravelHandlerForWorld(CurWorld);
        AGameModeBase *CurGameMode = CurWorld->GetAuthGameMode();

        if (!SeamlessTravelHandler.IsInTransition() && WorldPackageName == CurWorld->GetOutermost()->GetFName() && CurGameMode != NULL)
        {
            AController *TravelPlayer = this;
            CurGameMode->HandleSeamlessTravelPlayer(TravelPlayer);
        }
        else
        {
            // This is the seamless travel fix for client loading before server and softlocking
            // Skip this for TransitionMapName
            FString TransitionMapString = GetDefault<UGameMapsSettings>()->TransitionMap.GetLongPackageName();
            FName TransitionMapName(*TransitionMapString);
            if (TransitionMapName != WorldPackageName)
            {
                LastCompletedSeamlessTravelCount = SeamlessTravelCount;
            }
        }
    }
}

```

You will incur an extra RPC during level transitions, but the impact of this should be minimal.

---

<div class="post-metadata">

**Author:** ![gollymashed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gollymashed](https://forums.unrealengine.com/u/gollymashed)\
**Post date:** [June 17, 2022, 10:13am UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/2 "2022-06-17T10:13:27Z")

</div>

I’ve been struggling with this issue in 5.0.2, and had also narrowed it down to the server not receiving the ServerNotifyLoadedWorld RPC calls (but hadn’t got any further than that). It’s a huge relief to see that you’ve found a workaround!

I am having some trouble implementing it and I’m not incredibly experienced with c++, so apologies if this is a basic question. I did already have a c++ class that inherits and overrides some functions from PlayerController.h (by including it in the header), but when I paste the workaround in and switch the PlayerController names to the names of my player controller there are a few errors:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/b/a2b173d47d4153f3dde7eb97dcc7c2f3660b3052.png)

My PlayerControllerBase.h file is as follows:

> #pragma once
> 
> #include “CoreMinimal.h”  
> #include “GameFramework/PlayerController.h”  
> #include “PlayerControllerBase.generated.h”
> 
> UCLASS()  
> class APlayerControllerBase : public APlayerController  
> {  
> GENERATED\_BODY()
> 
> public:  
> virtual void OnRep\_Pawn() override;
> 
> UFUNCTION(BlueprintCallable, Category = “Start Spectating Player Controller”)  
> void StartSpectating();
> 
> UFUNCTION(Client, Reliable)  
> void Client\_StartSpectating();
> 
> UFUNCTION(BlueprintCallable, Category = “Start Spectating Player Controller”)  
> void StartPlaying();
> 
> virtual void NotifyLoadedWorld(FName WorldPackageName, bool bFinalDest) override;
> 
> UFUNCTION(Reliable, Server, WithValidation, SealedEvent)  
> void ServerNotifyLoadedWorldWorkaround(FName WorldPackageName);  
> };

And the .cpp file includes PlayerControllerBase.h and I’ve just added the workaround to the end, and also tried including Net/UnrealNetwork.h and GameFramework/GameModeBase.h. Any pointers in the right direction would be greatly appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![asmallcrayon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@asmallcrayon](https://forums.unrealengine.com/u/asmallcrayon)\
**Post date:** [June 17, 2022, 1:13pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/3 "2022-06-17T13:13:38Z")

</div>

I’m having a similar issue, but when implementing your solution I see that the Last and Current travel counts are now the same (previously were not), however bInCorrectWorld still returns false for me preventing completion and still only when the client loads first.

Before your change

```auto
LogPlayerController: Verbose: APlayerController::HasClientLoadedCurrentWorld: Client /Game/Maps/MAP_01_P, World: /Game/Maps/MAP_01_P
LogPlayerController: Verbose: Last Count 0, Current Count 1

```

After your change, it appears to hold the temp transition level in GetClientWorldPackageName().

```auto
LogPlayerController: Verbose: APlayerController::HasClientLoadedCurrentWorld: Client /Temp/Untitled_1, World: /Game/Maps/MAP_01_P
LogPlayerController: Verbose: Last Count 1, Current Count 1

```

This line probably needs a bit of adjustment to handle the case where no specific transition map is specified.

```auto
const FString TransitionMapString = GetDefault<UGameMapsSettings>()->TransitionMap.GetLongPackageName();

```

---

<div class="post-metadata">

**Author:** ![gollymashed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gollymashed](https://forums.unrealengine.com/u/gollymashed)\
**Post date:** [June 17, 2022, 6:01pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/4 "2022-06-17T18:01:15Z")

</div>

Quick update on this. Since I couldn’t get the fix working on my Player Controller subclass, I have built the engine from source and added the fix straight into the PlayerController.cpp and now the server is consistently calling HandleSeamlessTravelPlayer. Thanks so much for sharing the fix!

If anyone is able to point me towards the correct way to implement this into the subclass I’d be extremely grateful, so that I can avoid building the engine from source.

---

<div class="post-metadata">

**Author:** ![liquid.mike](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/liquid.mike/32/88717_2.png) [@liquid.mike](https://forums.unrealengine.com/u/liquid.mike)\
**Post date:** [June 17, 2022, 9:00pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/5 "2022-06-17T21:00:06Z")

</div>

@gollymashed I apologize. The above solution has a typo and there’s another step (Other than those missing header files, sorry about that too)

You need to open “YourProjectName.Build.cs” and you should have a line in there that looks like this

```cpp
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", ... }

```

Just add “EngineSettings” to that array.

And then there’s an error in the code I posted

```cpp
bool AYourPlayerControllerName::ServerNotifyLoadedWorld_Validate(FName WorldPackageName)

```

Should be

```cpp
bool AYourPlayerControllerName::ServerNotifyLoadedWorldWorkaround_Validate(FName WorldPackageName)

```

We wanted to avoid compiling the engine as well, so I hope that works for you! If not let me know.

---

<div class="post-metadata">

**Author:** ![liquid.mike](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/liquid.mike/32/88717_2.png) [@liquid.mike](https://forums.unrealengine.com/u/liquid.mike)\
**Post date:** [June 17, 2022, 9:00pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/6 "2022-06-17T21:00:57Z")

</div>

Right you are, we have a transition map so we didn’t run into that issue!

---

<div class="post-metadata">

**Author:** ![thegattis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thegattis](https://forums.unrealengine.com/u/thegattis)\
**Post date:** [June 21, 2022, 7:13am UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/7 "2022-06-21T07:13:25Z")

</div>

Also, the fix worked for me @liquid.mike thanks! I applied the code directly to engine source.

---

<div class="post-metadata">

**Author:** ![thegattis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thegattis](https://forums.unrealengine.com/u/thegattis)\
**Post date:** [June 21, 2022, 7:13am UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/8 "2022-06-21T07:13:29Z")

</div>

@liquid.mike Wow I’ve been banging my head against the wall for almost a month after noticing this issue appear after upgrading to UE5.  
How long has this been an issue and if it was reintroduced, how has this not been more posted about? This seems like a critical error regarding all games that are using UE5.

---

<div class="post-metadata">

**Author:** ![Monster\_Tooth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monster_tooth/32/555871_2.png) [@Monster\_Tooth](https://forums.unrealengine.com/u/Monster_Tooth)\
**Post date:** [July 29, 2022, 4:24am UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/10 "2022-07-29T04:24:53Z")

</div>

Can you post the whole cpp and header files, getting errors trying to implement this and think I am missing something

---

<div class="post-metadata">

**Author:** ![liquid.mike](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/liquid.mike/32/88717_2.png) [@liquid.mike](https://forums.unrealengine.com/u/liquid.mike)\
**Post date:** [August 2, 2022, 10:08pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/11 "2022-08-02T22:08:44Z")

</div>

There were some errors in the original post. Please see my reply [UE5 Seamless travel bug found. We found the cause, and also have a workaround - #5 by liquid.mike](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/5)

---

<div class="post-metadata">

**Author:** ![Monster\_Tooth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monster_tooth/32/555871_2.png) [@Monster\_Tooth](https://forums.unrealengine.com/u/Monster_Tooth)\
**Post date:** [August 3, 2022, 3:23am UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/13 "2022-08-03T03:23:24Z")

</div>

> [@liquid.mike](#):
>
> EngineSettings

If anyone else runs into trouble here is what to include in your cpp along with the corrections shown above

#include “Net/UnrealNetwork.h”  
#include “GameFramework/GameModeBase.h”  
#include “GameMapsSettings.h”

---

<div class="post-metadata">

**Author:** ![JEFFREY\_EPSTElN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JEFFREY\_EPSTElN](https://forums.unrealengine.com/u/JEFFREY_EPSTElN)\
**Post date:** [September 13, 2022, 4:56pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/14 "2022-09-13T16:56:24Z")

</div>

Ran into this problem as well. I believe there is a side effect happening with this workaround. Namely, `InitSeamlessTravelPlayer` is now getting called twice for each player. This results in GameMode’s `NumPlayers` being double-counted, so it always thinks twice as many players are connected compared to how many actually are. We use `NumPlayers` in our multiplayer logic, and while I could probably work further around this, that feels like a bad idea. Has anyone else encountered this?

---

<div class="post-metadata">

**Author:** ![havenking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/havenking/32/1161816_2.png) [@havenking](https://forums.unrealengine.com/u/havenking)\
**Post date:** [September 21, 2022, 11:34pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/15 "2022-09-21T23:34:28Z")

</div>

I think I ran into this problem too, when I host the game in my PC everyone travels to the map, when I host the game on my brother’s PC the same, but when I host the game on my less powered notebook I and my brother keep stuck in the loading.

So my question is, if the bug has been reported in Jun 16, why its still happening now in Sep 21?

Edit1: It seems that the unreleased 5.1 addresses this, the function HasClientLoadedCurrentWorld check return is now

```auto
return (Connection->GetClientWorldPackageName() == GetWorld()->GetOutermost()->GetFName());

```

---

<div class="post-metadata">

**Author:** ![FaceW.TearsOfJoy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FaceW.TearsOfJoy](https://forums.unrealengine.com/u/FaceW.TearsOfJoy)\
**Post date:** [October 21, 2022, 7:50pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/16 "2022-10-21T19:50:37Z")

</div>

If possible I would like to know if the unreleased 5.1 actually fixed this issue or not, did you test it or have any information on this?

Just to know if it’s worth waiting for full 5.1 release (5.1 Preview 2 currently available to download, so it shouldn’ take that long hopefully).

So we don’t have to implement this workaround, where as JEFFREY\_EPSTEIN mentioned above, this workaround causes some side effects (if true).

Thank you!

---

<div class="post-metadata">

**Author:** ![havenking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/havenking/32/1161816_2.png) [@havenking](https://forums.unrealengine.com/u/havenking)\
**Post date:** [October 21, 2022, 8:13pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/17 "2022-10-21T20:13:38Z")

</div>

I didn’t tested the 5.1 yet due to project plugins. I suggest you ask in the Unreal Slackers discord if anyone knows it the problem was fixed.

---

<div class="post-metadata">

**Author:** ![WizardCell](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/wizardcell/32/1194688_2.png) [@WizardCell](https://forums.unrealengine.com/u/WizardCell)\
**Post date:** [October 30, 2022, 1:15pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/18 "2022-10-30T13:15:49Z")

</div>

Might I ask if this bug was reported somewhere here: [https://issues.unrealengine.com/](https://issues.unrealengine.com/) ? I’m asking before I report it myself.

---

<div class="post-metadata">

**Author:** ![YogevNa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YogevNa](https://forums.unrealengine.com/u/YogevNa)\
**Post date:** [October 31, 2022, 3:37am UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/19 "2022-10-31T03:37:36Z")

</div>

Still happens on 5.0.3 for me.

---

<div class="post-metadata">

**Author:** ![WizardCell](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/wizardcell/32/1194688_2.png) [@WizardCell](https://forums.unrealengine.com/u/WizardCell)\
**Post date:** [October 31, 2022, 11:45pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/20 "2022-10-31T23:45:02Z")

</div>

Okay so I missed what was noted by @havenking . They seem to have fixed it in 5.1. They have also added one line to `ServerNotifyLoadedWorld` which handles remapping a package name for networking.

---

<div class="post-metadata">

**Author:** ![Get\_Gooder](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Get\_Gooder](https://forums.unrealengine.com/u/Get_Gooder)\
**Post date:** [November 1, 2022, 6:01pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/21 "2022-11-01T18:01:19Z")

</div>

Do you happen to have the commit hash for the fix?

EDIT: Here’s the commit if anyone is curious: [https://github.com/EpicGames/UnrealEngine/commit/503690c293cbfa284611c2d1e58abf79fa9b97bc](https://github.com/EpicGames/UnrealEngine/commit/503690c293cbfa284611c2d1e58abf79fa9b97bc)

---

<div class="post-metadata">

**Author:** ![TobyTheSunSpear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TobyTheSunSpear](https://forums.unrealengine.com/u/TobyTheSunSpear)\
**Post date:** [November 3, 2022, 10:48pm UTC](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652/22 "2022-11-03T22:48:10Z")

</div>

Hi!  
Currently struggling with this bug so thank you so much for providing the report and a workaround.

Unfortunately we don’t use a transition map and I have no knowledge of how this should look, do you know what it should look like for someone not using a transition map?

[Next page](https://forums.unrealengine.com/t/ue5-seamless-travel-bug-found-we-found-the-cause-and-also-have-a-workaround/583652.md?page=2)
