sinbad / SPUD

Steve's Persistent Unreal Data library
MIT License
308 stars 45 forks source link

Automated storing on travel does not work when using Seamless Travel #4

Closed poettlr closed 3 years ago

poettlr commented 3 years ago

Hello,

It seems that Unreal is not calling the FCoreUObjectDelegates::PreLoadMap delegate when traveling using seamless travel. Therefore SPUD is not picking up the transition and is not storing data by default.

There is a delegate defined in World FWorldDelegates::FOnSeamlessTravelStart that might do the trick. I currently do it manually via blueprint but will add this in my GameInstance to see if it resolves the issue.

Cheers, Nikolaus

sinbad commented 3 years ago

Aha, thanks I haven't had a need to use seamless travel since we're not making a multiplayer game. I will look at adding a seamless travel point to the examples since that's the smoke test.

sinbad commented 3 years ago

image

Hmm, I just started making a test for this and I'm getting PreLoadMap calls happening even on seamless travel. I'm using ServerTravel <newmap> (console command since I'm triggering from Blueprints) and I get both the pre- and post- load calls happening exactly as with OpenLevel. This is on 4.26.1

sinbad commented 3 years ago

I haven't changed the default GameMode in the examples so that has bUseSeamlessTravel=true still. I can even bounce backwards and forwards between FirstPersonExampleMap and SecondaryMap using the servertravel command and SPUD's persisting everything fine in both maps AFAICT. 🤔

sinbad commented 3 years ago

I've tested that in PIE and in a packaged build, same result. It's pretty fast to test using the console.

However, I'm not using a transition map yet. Perhaps that's the issue?

poettlr commented 3 years ago

Wait, so do you have bUseSeamlessTravel set to true or not? Because as far as I know servertravel will fallback to the default transition if it's not set. Also, there should be a default transitionmap that's being used. I'll dig a bit deeper into our current setup tomorrow to confirm if there is anything particularly weird with what I'm doing.

Thanks for looking into that!

sinbad commented 3 years ago

AGameModeBase sets the default bUseSeamlessTravel to 1 (true) and the example GM derived from it doesn't change that. I didn't dig any further than that though yet.

poettlr commented 3 years ago

I could not rest :) AGameModeBase doesn't set bUseSeamlessTravel. Its default initialized as false (though it uses only 1 bit). When not setting bUseSeamlessTravel explicitly and executing the "ServerTrave" command I get the same output as you do. But when setting the flag to true and trying to load a map with "ServerTravel" I now get the expected output of:

LogPackageName: SearchForPackageOnDisk took 0.074s to resolve Map_Secondary. LogGameMode: Warning: CanServerTravel: Seamless travel currently NOT supported in single process PIE.

Which is the common pain point when using seamless travel (it only works in Standalone and packaged game as far as I know).

Cheers, Nikolaus

sinbad commented 3 years ago

Ahh sorry I completely misread the bitfield as "true", I blame being away from C++ for too long. I'll take another look. Only being able to test in a packaged build is going to be a pain :/

poettlr commented 3 years ago

You can also try Standalone if your SPUD test works with that?

sinbad commented 3 years ago

No as I had to put in the FAQ, Standalone is not reliable for reasons I never managed to figure out. I discovered after discussions with others that random Standalone failures are not unusual and lots of people just ignore it and use PIE or packaged only. I remember I had all kinds of issues with video mode configuration in Standalone that was fine in packaged games.

sinbad commented 3 years ago

I might also have to change the LoadGame options thinking about it - that currently uses OpenLevel to travel to the map the user was on but I guess I should provide the option to ServerTravel instead? I don't know much about multiplayer in UE yet but I assume OpenLevel might require players to reconnect on load otherwise?

sinbad commented 3 years ago

OK, that wasn't that hard (apparently...unless I've missed something). I used FWorldDelegates::OnSeamlessTravelTransition since it's the last moment before the transition happens, so won't miss anything that happens in between the seamless travel request and the level being ready. It appears to work fine in packaged mode, and actually things seem fine in Standalone mode now too (possibly the problems I saw before have been fixed in 4.26 since I started this on 4.25).

I haven't yet changed the LoadGame behaviour to have the option of ServerTravel, perhaps you can let me know if that's needed or not & open another issue if so? Like I say I don't really have a good understanding of multiplayer yet. Thanks.