I have a custom weapon which on creation should call a function in the custom
game state to “register itself”, so the game state has it in a variable for quick
reference. After setting this up everything compiles fine. When starting a PIE
session, the editor crashes. From then on if anything attempts to touch any of
the assets involved, the editor crashes:
Opening a map with the custom game state referenced.
Opening the weapon class to edit.
Opening any blueprint interface used in either of them.
Other things to note:
I’m on 4.1.1 because even a working version crashes 4.2 on startup.
Everything in the project is made with Blueprints.
What matters is making the call. The class it’s called from or the data passed
seems to be irrelevant.
@Tim Hobson: There is no crash with the racer example. It seems that the 4.2 issue
is a separate one, some kind of an “assertion on asset load”. Max Preussner knows
about it already, I just mentioned it to explain why I couldn’t test it in 4.2.
@dmacesic: Interesting. I’ll set up a test to see if I can get a valid game state object
to begin with.
Just as a reference, just in case it helps you or someone else, I’ve resolved my issue. It seems the way the world pointer is managed in the player’s context is a bit different. I was using an invalid UWorld pointer to generate a Slate widget from a static function. I have used the example in Shooter Game 4.2, and used FLocalPlayerContext to get a proper pointer to the world to get the game state.
APlayerController* pc = GetOwningPlayerController();
// pass this to static Slate widget creation function and do
UWorld* world = Context.GetWorld();
AGameGameState* gameState = world->GetGameState<AGameGameState>();
//gameState is no longer NULL