Player falls thru terrain when first loaded on Win64 compiled games

Ok… …so when I simulate my game and I load the current level my player drops into my level fine.

Now… …I compile my game for WIndows, 64-bit, and run that game when my player drops into my level, the terrain, height map, has not rendered yet and as a result, the player falls thru the map.

So, I assume that I did something to cause this issue; however, I don’t know where I should start looking.

Any recommendations as to how I can speed up terrain generation (or) slow down when my player spawns into a level?

1 Like

It’s a common problem, especially when spawning levels or players. Anything dynamic.

Basically, you have to code around it.

You can wait until something on the landscape ( a well know actor ) has appeared before spawning the player.

You can set the player gravity to zero. Later setting it to normal once a line trace tells you the land is there.

Another option, is to put the player on a simple actor, such as a cube, and later remove the cube.

4 Likes

Hello ClockworkOcean.

Thanks for the quick reply!

I like the idea of setting the player gravity to zero and later setting it back to normal.

Funny given the cube idea in that when I first spawn into my level (assuming it is not from a save) I do spawn in on top of a persistent object to mitigate this issue; however, my issue now is that if I save the game and then reload not on top of a persistent object, I sometimes fall thru the not rendered yet terrain.

I do hear you in that you could have a simple temporary actor that spawns; hopefully, first under the player and after some time after the terrain has generated remove that temporary actor.

Going to try the zero gravity thing first…

…some more observations given this issue is that I have a simple cut scene before loading my game level of which this cut scene has a “Skip” button. If I “Skip” right away, my level spawn seems to be fine; however, if I wait to the end, or about the end, of the cut scene, I seem to fall thru the terrain.

Could this be a resource management issue in that if my previous level is very complicated that the freeing of these previous resources is impacting the loading of my new resources?

2 Likes

Not sure about that actually, but I do know that I had to specifically write my level streaming code to wait until the player start existed, before spawning the player.

1 Like

Ok… …so the issue??? according to the “Output Log” is that the “EventBeginPlay” for my player, “FirstPersonCharacter_C_0” is running before the map is loaded as indicated by the “LogLoad… …LoadMap…”. See the snip of log messages below.

Is there a way to wait until a desired “LoadMap” is completed???

For that matter… …seems the AISystem is starting before the LoadMap has completed so is it plausable that my AI might also fall off the map???

Log snips…

LogBlueprintUserMessages: [MainMenuWidget_C_0] LoadPlayerDataPart1 Completed Successfully…
LogNet: Browse: /Game/Maps/Level1/Level1?FromMainMenu
LogLoad: LoadMap: /Game/Maps/Level1/Level1?FromMainMenu
LogWorld: BeginTearingDown for /Game/Maps/UEDPIE_0_MainMenuLevel
LogWorld: UWorld::CleanupWorld for MainMenuLevel, bSessionEnded=true, bCleanupResources=true
LogSlate: InvalidateAllWidgets triggered. All widgets were invalidated
LogAudio: Display: Audio Device unregistered from world ‘None’.
LogUObjectHash: Compacting FUObjectHashTables data took 3.66ms
LogAudio: Display: Audio Device (ID: 34) registered with world ‘Level1’.
LogAIModule: Creating AISystem for world Level1
LogLoad: Game class is ‘FirstPersonGameMode_C’
LogWorld: Bringing World /Game/Maps/Level1/UEDPIE_0_Level1.Level1 up for play (max tick rate 0) at 2022.05.07-11.32.25
LogWorld: Bringing up level for play took: 0.032089
LogBlueprintUserMessages: [FirstPersonGameMode_C_0] ?FromMainMenu
LogBlueprintUserMessages: [FirstPersonGameMode_C_0] FP GameMode (True): FromMainMenu
LogBlueprintUserMessages: [FirstPersonGameMode_C_0] FixedOptionString: FromMainMenu
LogBlueprintUserMessages: [Level1_C_0] Level1 Event BeginPlay
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] FPC->EventBeginPlay; Level1
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Create Health Bar Widget
LogViewport: Display: Viewport MouseCaptureMode Changed, CapturePermanently_IncludingInitialMouseDown → CapturePermanently
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] FPC Options String:?FromMainMenu
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Load Player Data…
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Doing LoadPlayerDataPart2…
LogLoad: Took 0.205146 seconds to LoadMap(/Game/Maps/Level1/Level1)
LogBlueprintUserMessages: [Level1_C_0] Cast to FPC worked!
LogBlueprintUserMessages: [Level1_C_0] Health Bar Ref Valid!!
LogBlueprintUserMessages: [Level1_C_0] Play Cave Sound

I have no idea how you can control this process, I’m afraid…

Where are you spawning the player from?

Hello eblade.

Thanks for the reply.

I have two PlayerStarts: the start of the game start and a respawn start.

From there in the FirstPersonCharacter EventBeginPlay I will load from the last saved game if there is a last saved game.

A saved game saves the location and rotation of the player at that save point in time.

What are you thinking???

OK.

I have a “solution” in that per ClockworkOcean I set the FirstPersonCharacter to have a gravity of 0 at the beginning of EventBeginPlay.

I then execute the code in EventBeginPlay which sets the location of the player given the last save, if there is one, or the predefined PlayerStart.

I then wait 2 seconds at the end of the EventBeginPlay code and follow that up with setting gravity back to 1.0.

This seems to work both when simulating and when the game is compiled for Windows 64bit.

2 seconds seems a tad too long; however, I don’t know if this will get worse as I develop the game, or not.

1 Like

Might be best to avoid timers, because how long it takes really depends on the hardware.

Like I say, waiting until I could see the player start did it for me :wink:

1 Like

@ClockworkOcean is there seriously no ‘Wait for loading’ delay node that Epic gave us?

I thought ‘wow’ to your solutions above, because they work, yet so easy for Epic to do this behind the scenes code for us - when the game loads. (Even code [built into PlayerCharacter] for a cube to auto spawn below the Player’s Capsule - and not destroy until the Engine loads X.)

  1. So I am surprised if it does not exist? (Ive seen no one give a tutorial for code-delay needed for a loading screen - a check list of things that tell the Engine that need to load before the level starts??)

  2. I’m shocked at how many things the devs left unresolved to prevent fatal flaws (when using the Starter templates). (My player kept falling thru - in the Engine play - after I setup the save game code. And I had no idea we had to code around terrain not loading before the Engine lets us play. How many others had this problem and gave up on the Engine because they didn’t know the issue?)

  3. It would be so easy for Epic (those who know), to build code in the PlayerCharacter, then have a bool WaitTilLoad? Then give us a companion bool setting in [terrain actor or whatever Epic knows loads the slowest]. Thus we can set the game to wait for X to load before the Engine tries to Spawn the characters. And this delay bool could also execute a loading screen widget: DelayWidget To Display? = W.

My complaint is that Epic knows all the stats of what their Engine loads first or the slowest. Thus they should have put in this fix for us. My project was stalled a week because my player was falling thru and I had no idea why.

1 Like

There might be a node, but I never found it :slight_smile:

1 Like

Thanks for the reply. Youre the pro, so I’ll assume it doesnt exist.
Makes me wonder what all the successful game devs had to code to make basic game functions work.
Can you direct me to the proper thread or forum - for a list of known game issues/hurdles/things that are missing (from game templates) - that game devs have to add themselves? I.e. has anyone made a thread to list the basics that must be added to get a working game?

  • Need to add delay-spawn code so player doesnt fall thru the level before terrain/X loads.
  • How to make a Save game [system/manager/plugin] that correctly saves/loads all variables of Interactable-actors in map (never got this to work, old tuts are incomplete, and former free content is outdated for UE4.27)
  • Need to manually add code to make GamePad controller work for Widget navigation.

There is no one place or tutorial. I suspect there is a way to know if a streaming level has finished loading in C++, but I only use BP.

The best thing to know, is that if you get as far as making a game, then you have the skills to make a good work around for these random things the engine likes to throw at you.

Where in the game are you creating the character, though?

This is not a problem that normally people have to deal with, so it sounds like you’re bypassing the usual process for spawning the player.

I think you’ll find a lot of people on here asking this question. If you’re spawning players, the landscape not being ready is pretty common :slight_smile:

Hello eblade.

Thanks for your reply.

So I here you in that a few months ago this wasn’t a problem; however, here I am.

As to bypassing the usual process for spawning the player… …I am not aware as to how I should, or shouldn’t, be spawning the player.

Not sure how to communicate what I am doing to figure out if I am doing something wrong. I am certain that I do not know how to exactly, or to most correctly, load a level.

So… …how about this… …I will share some log messages in hopes that this might highlight what I am doing wrong…

…to start, I have a MainMenu level. The log messages when I start this level simulation are as follows:


LogTemp: Repeating last play command: Simulate
LogPlayLevel: PlayLevel: No blueprints needed recompiling
PIE: New page: SIE session: MainMenuLevel (May 8, 2022, 6:06:09 PM)
LogOnline: OSS: Creating online subsystem instance for: NULL
LogOnline: OSS: TryLoadSubsystemAndSetDefault: Loaded subsystem for module [NULL]
LogPlayLevel: Creating play world package: /Game/Maps/UEDPIE_0_MainMenuLevel
LogPlayLevel: PIE: StaticDuplicateObject took: (0.003250s)
LogAIModule: Creating AISystem for world MainMenuLevel
LogPlayLevel: PIE: World Init took: (0.000870s)
LogPlayLevel: PIE: Created PIE world by copying editor world from /Game/Maps/MainMenuLevel.MainMenuLevel to /Game/Maps/UEDPIE_0_MainMenuLevel.MainMenuLevel (0.004214s)
LogUObjectHash: Compacting FUObjectHashTables data took 2.74ms
LogBlueprintUserMessages: [MyGameInstanceBP_C_0] MyGameInstanceBP Event Init
LogAudio: Display: Creating Audio Device: Id: 2, Scope: Unique, Realtime: True
LogAudioMixer: Display: Audio Mixer Platform Settings:
LogAudioMixer: Display: Sample Rate: 48000
LogAudioMixer: Display: Callback Buffer Frame Size Requested: 1024
LogAudioMixer: Display: Callback Buffer Frame Size To Use: 1024
LogAudioMixer: Display: Number of buffers to queue: 2
LogAudioMixer: Display: Max Channels (voices): 32
LogAudioMixer: Display: Number of Async Source Workers: 0
LogAudio: Display: AudioDevice MaxSources: 32
LogAudio: Display: Using built-in audio occlusion.
LogAudioMixer: Display: Initializing audio mixer.
LogAudioMixer: Display: 0: FrontLeft
LogAudioMixer: Display: 1: FrontRight
LogAudioMixer: Display: Using Audio Device Realtek HD Audio 2nd output (Realtek(R) Audio)
LogAudioMixer: Display: Initializing Sound Submixes…
LogAudioMixer: Display: Creating Master Submix ‘MasterSubmixDefault’
LogAudioMixer: Display: Creating Master Submix ‘MasterReverbSubmixDefault’
LogAudioMixer: Display: Creating Master Submix ‘MasterEQSubmixDefault’
LogAudioMixer: FMixerPlatformXAudio2::StartAudioStream() called
LogAudioMixer: Display: Output buffers initialized: Frames=1024, Channels=2, Samples=2048
LogAudioMixer: Display: Starting AudioMixerPlatformInterface::RunInternal()
LogAudioMixer: Display: FMixerPlatformXAudio2::SubmitBuffer() called for the first time
LogInit: FAudioDevice initialized.
LogAudio: Display: Audio Device (ID: 2) registered with world ‘MainMenuLevel’.
LogLoad: Game class is ‘MainMenuGameMode_C’
LogWorld: Bringing World /Game/Maps/UEDPIE_0_MainMenuLevel.MainMenuLevel up for play (max tick rate 0) at 2022.05.08-22.06.09
LogWorld: Bringing up level for play took: 0.000280
LogOnline: OSS: Creating online subsystem instance for: :Context_21
LogGameMode: FindPlayerStart: PATHS NOT DEFINED or NO PLAYERSTART with positive rating
LogNativeClassHierarchy: Verbose: Native class hierarchy updated for ‘MovieSceneCapture’ in 0.0003 seconds. Added 20 classes and 0 folders.
PIE: Server logged in
PIE: Play in editor total start time 0.088 seconds.

I next press the “Possess” button. I then press my “Start” button which runs my intro cut scene of which I can wait until the end or press “Skip”. I pressed skip and the following log messages occur. The result was my player successfully spawning after the landscape appeared. Note that I am doing the gravity=0 and gravity=1 thing.


LogBlueprintUserMessages: [MainMenuWidget_C_0] LoadPlayerDataPart1 Completed Successfully…
LogNet: Browse: /Game/Maps/Level1/Level1?FromMainMenu
LogLoad: LoadMap: /Game/Maps/Level1/Level1?FromMainMenu
LogWorld: BeginTearingDown for /Game/Maps/UEDPIE_0_MainMenuLevel
LogWorld: UWorld::CleanupWorld for MainMenuLevel, bSessionEnded=true, bCleanupResources=true
LogSlate: InvalidateAllWidgets triggered. All widgets were invalidated
LogAudio: Display: Audio Device unregistered from world ‘None’.
LogUObjectHash: Compacting FUObjectHashTables data took 3.96ms
LogAudio: Display: Audio Device (ID: 5) registered with world ‘Level1’.
LogAIModule: Creating AISystem for world Level1
LogLoad: Game class is ‘FirstPersonGameMode_C’
LogWorld: Bringing World /Game/Maps/Level1/UEDPIE_0_Level1.Level1 up for play (max tick rate 0) at 2022.05.08-22.12.36
LogWorld: Bringing up level for play took: 0.033971
LogBlueprintUserMessages: [FirstPersonGameMode_C_0] ?FromMainMenu
LogBlueprintUserMessages: [FirstPersonGameMode_C_0] FP GameMode (True): FromMainMenu
LogBlueprintUserMessages: [FirstPersonGameMode_C_0] FixedOptionString: FromMainMenu
LogBlueprintUserMessages: [Level1_C_1] Level1 Event BeginPlay
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] FPC->EventBeginPlay; Level1
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Create Health Bar Widget
LogViewport: Display: Viewport MouseCaptureMode Changed, CapturePermanently_IncludingInitialMouseDown → CapturePermanently
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] FPC Options String:?FromMainMenu
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Load Player Data…
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Doing LoadPlayerDataPart2…
LogLoad: Took 0.176607 seconds to LoadMap(/Game/Maps/Level1/Level1)
LogBlueprintUserMessages: [Level1_C_1] Cast to FPC worked!
LogBlueprintUserMessages: [Level1_C_1] Health Bar Ref Valid!!
LogBlueprintUserMessages: [Level1_C_1] Play Outdoor Sound
LogBlueprintUserMessages: [EarthGolumMasterAi_2] EarthGolumMasterAi->Mood
LogStreaming: Display: UWorld::AddToWorld: updating components for /Game/Maps/Level1/UEDPIE_0_Cave3_CaveParts_StuffInRooms took (less than) 32.75 ms
LogD3D11RHI: Display: Temp texture streaming buffer not large enough, needed 8388608 bytes
LogBlueprintUserMessages: [EarthGolumMasterAi_2] EarthGolumMasterAi->Mood

Does any of the above show something that I might be doing incorrectly?

Some more information… …I am using “Open Level (by Name)” to open “Level1” which is my first game level. I am feeding in a level name, an options string and I have “Absolute” checked. I am running “Open Level (by Name)” in a function called “LoadPlayerDataPart1” which is in my custom game instance called “MyGameInstanceBP”. This BP also manages loading, saving and clearing game state data.

While the “LoadPlayerDataPart1” function is in “MyGameInstanceBP”, I am calling this function from a “Cast To MyGameInstanceBP” given the returned value from “Get Game Instance” in my “MainMenuWidget” BP.

ok, so if you don’t know how the player spawn happens, you probably haven’t changed anything in that regard… i hope :slight_smile:

If you open your level, and hit Play In Editor, with it set to start at a PlayerStart (as opposed to “at current camera position”) does it do the right thing then?

This might? tell us if it’s the level that is broken, or the load process, or something along those lines…

I’m not exactly sure where to start, so I’m kind of just stabbing in the dark. Unless you’ve built some sort of custom processes for loading and for spawning the player, normally the game will finish loading before it fires off all the BeginPlays, and I believe the default GameMode behavior is to wait until the player clicks on something before it starts spawning pawns. If you’re using some other base other than what comes in the stock engine, though, I don’t really know what’s happening there.

Hello eblade.

Thank you for the reply.

So all UE learning has come from YouTube and Googling. Some information is good and other information is not so good.

My fear is that the combination of all pieces of information has broken something.

Anyway… …my main game level is called “Level1”. There are two “PlayerStart” instances in this level of which the intended purpose for each is as follows:

  1. PlayerStart; PlayerStartTag=Please. This is the starting point when a new game is played. This is also the point where you go if you fall off the terrain and when you cross a “world floor boundary” static mesh.

  2. PlayerStart; PlayerStartTag=Level1Respawn. This is the starting point when you return from the “Purgatory” level which is where you go when you die (like Sea Of Theives).

You say “Play In Editor”. All I see is the “Play” button of which there are choices. Below is a screenshot of my typical debugging method.

In general, this works fine. My process is click the “Play” button. Then, I have to click the “Possess” button.

However, what is weird is that when I play “Level1” more often than not it will start the level at the “PlayerStart; PlayerStartTag=Level1Respawn” position and not the “PlayerStart; PlayerStartTag=Please” position.

Maybe this is a clue as to some issue?

Also, if you examine, or re-examine, the last set of logs that “Level1_C_1” BeginPlay and “FirstPersonCharacter_C_0” BeginPlay start before the LogLoad message claim that Level1 has been loaded.

My claim is that is my issue. Would you agree?

I would claim that the EventBeginPlay for maybe everything but the level BluePrint should wait until “Level1” has been loaded. Maybe???

Ok… …so my level BluePrint for “Level1” has its “EventBeginPlay” only setting up the ambiance audio. No references to the player character…

I do have a custom GameInstance of which its intent is to manage saves and loads.

I also have a custom FirstPersonGameMode of which its intent is to manage which StartingPoint should be considered based on what level is opening “Level1”.

Otherwise, below is a screenshot of the Project Settings → Project - Maps & Modes:

Thoughts?

Select “Selected Viewport” rather than Simulate. That will start the game immediately, rather than waiting until you hit Possess.