Download

Reloading level causes player character to fall through static platform

I’ve Googled this issue without much luck…

My level starts just fine, but if I call


UGameplayStatics::OpenLevel(this, FName(*LevelPath), true);

to reload the SAME level, my character immediately falls through the default SM_Template_Map_Floor.

Adjusting the player start position to an insane Z pos (like 5000) doesn’t seem to help either… he falls right through it.

Its happening about 90% of the time, and I’m not really sure why.

I’ve read suggestions that I should disable gravity, disable player input, enable flying, wait for some level loading to complete, or even ray trace directly downward to establish collision before re-enabling everything.

Is this pretty standard? Is anyone else having this experience?

Unfortunately this is a common issue, especially when you have level streaming. I recommend that you start the player as spectator (you can set this in game mode), and then restart the player a bit later. You can try using BeginPlay() for that, but unfortunately I’ve had the player fell through the map sometimes when I did that.

I moved my start position to 4000 so that my character would fall for a moment, and added a LineTraceSingleByChannel on a Timer inside my Character class.

It starts out registering a Hit on the default Floor actor, BUT when I reload the level via hotkey, the line trace fails to hit anything.

When I press Pause and select the Floor in the Details panel, all the parameters are the same.

As it turns out I’ll fall through Cylinders and Landscapes as well, so at this point I’m wonder if loading the level invalidated something with my Character instance?

OK I’ve solved the problem (albeit in a hackish way)

Opening a level *this *way doesn’t have working collision…


FString LevelPath = FString("/Game/Levels/Castle.Castle");

UGameplayStatics::OpenLevel(this, FName(*LevelPath), true);

But opening a level via command prompt works


GetWorld()->GetFirstPlayerController()->ConsoleCommand("open castle");

I have no idea what this difference is but it seems to correctly initialize physics.