Called AGameMode::RestartGame in PIE will crash Editor

Called AGameMode::RestartGame in PIE and then pressed ESC to exit PIE. Then the editor will crash everytime.

Does the AGame::RestartGame was designed to not used in PIE?
Or is it a bug?

How can I Restar Current Game correctly?

It is not crashed when RestartGame is called. But only crash at exit the PIE.

Hey -

Can you post the code you’re using to call RestartGame? If you comment this code out and compile again does the crash on exit still occur? Could you post the callstack and log files from the crash as well?

Cheers

AGameMode* MyGameMode = UGameplayStatics::GetGameMode(this);
if (MyGameMode)
{
MyGameMode->RestartGame();
}

put the code in any where will cause crash.
It is crashed at garbage collection not successfull.

You can just add this to any code. Even an action input.
Pressed a key to restart a game. Exit PIE. You will see the crash.

link text

link text

Hey -

I was able to reproduce the crash and have submitted a bug (UE-18252) to investigate the issue. I’m not sure what you are using the function call for however if it works for you it seems that the ResetLevel function does not crash on exit. Best of luck in your project.

Cheers

Thank you. I will try it.

Sorry but ResetLevel is not my expected.
It will delete the Pawn and will not respawn it.

I only need to set the level to its original load from disk and respawn the Pawn at startpoint.