C++ Saving Variables crash on Packaged Development Build

Hey guys!

I read the documentation and searched on AnswerHub for answers but I couldn’t find anything related.

My problem is pretty simple. I created a simple save system (pretty much the same as shown in the “Saving Your Game with C++” tutorial) that currently saves only one ‘uint32’ variable. It works fine in the editor, but when I packaged my game (Development) and tryed it out, the game simply stops to work at the point where the game saves. No error message, no nothing. It just freezes.

Maybe you guys have a clue? I’m working on Windows 8.1.

Sincerely

Can’t find how to edit my question but here is some information that could be really helpful: i’m using UE 4.4.3 binary release.

Ok, I found the problem. It’s an internal problem in my code.

So I have this code where I store the amount of deaths the player has. When I increase the amount, the game stops working. I used “variable++”, “variable += 1”, “variable = variable + 1” and even wrote a function just for this. Nothing works.

So here is the whole current code for this function:

UShroomysAdventure_SaveGame* LoadGameInstance = Cast<UShroomysAdventure_SaveGame>(UGameplayStatics::CreateSaveGameObject(UShroomysAdventure_SaveGame::StaticClass()));
LoadGameInstance = Cast<UShroomysAdventure_SaveGame>(UGameplayStatics::LoadGameFromSlot(LoadGameInstance->getSaveSlotName(), LoadGameInstance->getUserIndex()));
uint32 timesDiedGM = LoadGameInstance->getTimesDied();
timesDiedGM += 1;
    
UShroomysAdventure_SaveGame* SaveGameInstance = Cast<UShroomysAdventure_SaveGame>(UGameplayStatics::CreateSaveGameObject(UShroomysAdventure_SaveGame::StaticClass()));
SaveGameInstance->setTimesDied(timesDiedGM);
UGameplayStatics::SaveGameToSlot(SaveGameInstance, SaveGameInstance->getSaveSlotName(), SaveGameInstance->getUserIndex());

This will get executed right in this order in the Tick function (but I made sure that this code will executed once, so it can’t be a infinite loop. I did it with “bad programming style”. Just a boolean that checks if the code was executed). Maybe this is the problem? The score get’s load, value get’s changed in a copy of the variable, the original will be set to the copy.

Does anyone has a clue?

Can you show error log?

Sure here is the log that pops up:

Try to check your LoadGameInstance with IsValidLowLevel() before making changes to your int.

Hey TimGS!

Oops, sorry. I could think of that ^^ But no when I check the LoadGameInstance with IsValidLowLevel() there are no more problems. It saves perfectly. Thanks for that! I definitely need to do more error checking… :slight_smile:

Sincerely

Good. Now we can resolve this one. =)

btw if you still interested you can edit your question by hitting that little EDIT link under tag panel