SeamlessTravel implementation causing GetPlayerController Node lost reference on PIE

Greetings, I’m getting a really weird issue on PIEs…

A) My GameMode uses the seamlesstravel method to switch between maps (code from required methods on bottom).
B) I have a method on my playercontroller that does spawn a “selfdestroying” actor.
C) Calling this method with direct player input (CODE to key event) works perfectly, it spawns, init the timer and does destroy when the kill event is fired.
D) I have an UMG HUD with a button whose the click event is wired to the BP Node GetPlayerController 0, casts to my Controller class and fires “exactly” the same method.
E) On fire by HUD, I get no spawn on the game world while playing, “BUT”, on Stop Playing the instances are show on my world outliner and plus looks like they become placed actors asking for save the map to commit the changes caused by their inclusion.

Here are the overriden methods, if I do use the default (SUPER) ones I get no spawns by neither input methods.



void My_GameMode::PostSeamlessTravel()
{
	//Super::PostSeamlessTravel(); commented to custom behaviour
	if (GameSession != NULL)
	{
		GameSession->PostSeamlessTravel();
	}

	bWaitingForReadyController = true;

	// Picks player 0
	APlayerController * LocalClient = UGameplayStatics::GetPlayerController(this, 0);

	// Picks the map player Start
	AActor * BetterStart = K2_FindPlayerStart(LocalClient);

	LocalClient->StartSpot = BetterStart;
	
	// Setups Camera and HUD	
	LocalClient->SetViewTarget(BetterStart);
	LocalClient->ClientSetHUD(HUDClass);

	LocalClient->SpawnPlayerCameraManager();
	
	Cast<MyCameraManager>(LocalClient->PlayerCameraManager)->CleanCameraEffectsAndPP();
	RestartPlayer(LocalClient);
	Cast<AMyCharacter>(LocalClient->GetPawn())->BootPlayerAudioListener(); // Just a custom method to override audio sensing
}


bool My_GameMode::ReadyToStartMatch()
{
	//return Super::ReadyToStartMatch(); commented to custom behaviour
	return !bWaitingForReadyController;
}

void My_GameMode::HandleSeamlessTravelPlayer(AController*& C)
{
	//Super::HandleSeamlessTravelPlayer(C); commented to custom behaviour
}

void AVIDA_GameMode::StartNewPlayer(APlayerController* NewPlayer)
{
	//Super::StartNewPlayer(NewPlayer); commented to custom behaviour
	NewPlayer->InitPlayerState();
	NewPlayer->ClientSetHUD(HUDClass);
}


Looks like the HUD (whose is there just one instance running) is accessing another instance from something, but I have no idea what.

Any tips will be amazing.

Thank you

SOLVED

After a good night of sleep I decided to look on other places…
It’s not a problem from anything related to the SeamlessTravel but instead, my spawn method and my framework.

To avoid need to declare a const UWorld variable each time I need a World pointer and also to access a world pointer on UObjects, I got the “bad” idea of place a method GetWorldPtr on my helper library, something simple as that:


static UWorld * GetUWorldPtr() { return GWorld->GetWorld(); };

If I use this method as pointer provider to the spawn method I get the bug described above on PIE.

On the other hand if I do the usual way getting a pointer through the “standard” method


UWorld* const World = GetWorld();

Both HUD and key spawns the object…

I would like just to get now an answer about why these methods has diferent behaviours.

Thank you.