# Pawn is unpossessed after seamless travel

**URL:** <https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655>\
**Category:** Multiplayer & Networking\
**Tags:** seamless-travel, unreal-engine, Multiplayer, question\
**Created:** [May 27, 2019, 11:28am UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655 "2019-05-27T11:28:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yarsento](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yarsento](https://forums.unrealengine.com/u/yarsento)\
**Post date:** [May 27, 2019, 11:28am UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655/1 "2019-05-27T11:28:21Z")

</div>

Hi everybody,

we are working on a multiplayer game with 2 teams (sheeps and wolves). If a game is won, i’m using AGameMode::RestartGame to restart the same map using seamless travel. I’m using the match state WaitingToStart as a warmup phase in which only the sheeps are allowed to spawn. I override AGameMode::HandleMatchIsWaitingToStart and respawn the sheeps using RestartPlayer().  
The problem is that the sheep spawns but is unpossessed after.

If the listen server is a wolf, the pawn is unpossessed in the same server time (AGameState::GetServerWorldTimeSeconds()):

![278102-serveriswolf.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/b/bfb17297d7ff29e418559f284a191355bac0767e.png)

If the listen server is a sheep, the pawn is unpossessed a few hundred ms later:

![278103-serverissheep.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/c/2/4c2ae0dc4b1e0a5d619438914a1871b30cb90311.png)

Though if I debug the server instance of the game and set breakpoints in HandleMatchIsWaitingToStart and OnUnpossess, i can see that first OnUnpossess is called and then HandleMatchIsWaitingToStart and everything works fine. So in debugging they are called from FSeamlessTravelHandler::Tick.

OnUnpossess:

![278105-onunpossesscallstack.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/e/54edf11c8be9fe318e1e1742def1ab7649f5940a.png)

HandleMatchIsWaitingToStart:

![278104-handlematchiswaitingtostartcallstack.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/7/f9771357bd33c454508ecedddcc1d951519b8398.png)

Without debugging, OnUnpossess is called after HandleMatchIsWaitingToStart.

Does anyone have an idea why OnUnpossess is called after HandleMatchIsWaitingToStart or from where?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Punitiate](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Punitiate](https://forums.unrealengine.com/u/Punitiate)\
**Post date:** [May 27, 2019, 9:39pm UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655/2 "2019-05-27T21:39:53Z")

</div>

According to [Travelling in Multiplayer | Unreal Engine Documentation](https://docs.unrealengine.com/en-US/Gameplay/Networking/Travelling/index.html#seamlessandnon-seamlesstravel) pawns are not marked by default to persist across seamless travel, but player controllers are.

I suspect that this is happening because the OnUnpossess is being called as part of the pawn pending a destroy on seamless travel (According to your stack).

Can you double check that you’ve marked your pawns to persist?

---

<div class="post-metadata">

**Author:** ![yarsento](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yarsento](https://forums.unrealengine.com/u/yarsento)\
**Post date:** [May 28, 2019, 5:30am UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655/3 "2019-05-28T05:30:57Z")

</div>

Thanks for your answer! I haven’t done this, because I actually don’t want the pawns to persist. From my understanding, HandleMatchIsWaitingToStart() is being called as a result of World-\>BeginPlay(), as you can see in the upper callstack, which is being called from FSeamlessTravelHandler. So after seamless travel, new pawns should spawn, as I’m calling RestartPlayer in the HandleMatchIsWaitingToStart() (am I wrong?). The OnUnpossess should indeed be called via PawnPendingDestroy() from EndPlay() which is also called via FSeamlessTravelHandler from the same function, but before the World-\>BeginPlay() (RouteEndPlay in FSeamlessTravelHandler::Tick in line 5922, World-\>BeginPlay in the same function in line 6187). So it does not make sense to me that while playing without debugging OnUnpossess is called AFTER the new pawn is spawned in HandleMatchIsWaitingToStart. Am I missing something?

---

<div class="post-metadata">

**Author:** ![yarsento](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yarsento](https://forums.unrealengine.com/u/yarsento)\
**Post date:** [May 28, 2019, 9:18am UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655/4 "2019-05-28T09:18:38Z")

</div>

Ok, I’m very sorry, it was my bad. I forgot to clear a timer at the round end, which was setting the state to spectating and therefore destroying the pawn. So now it is working if the server is a sheep, but not if it is a wolf. I will go through the code again for any more timers etc…

---

<div class="post-metadata">

**Author:** ![yarsento](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yarsento](https://forums.unrealengine.com/u/yarsento)\
**Post date:** [May 28, 2019, 1:29pm UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655/5 "2019-05-28T13:29:28Z")

</div>

It’s finally working. My mistakes were: forgetting to clear a timer at the round end and thinking that FSeamlessTravelHandler would somehow wait until all clients are ready before the match was restarted 😕

---

<div class="post-metadata">

**Author:** ![Punitiate](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Punitiate](https://forums.unrealengine.com/u/Punitiate)\
**Post date:** [May 28, 2019, 9:31pm UTC](https://forums.unrealengine.com/t/pawn-is-unpossessed-after-seamless-travel/449655/6 "2019-05-28T21:31:19Z")

</div>

All good, sometimes simply asking the question helps us come to an answer ourselves. Good luck!
