Probably bug: Cant load class from savegame if it is not referenced anywhere else

The above example returns nothing as display name unless I add a class variable of the same type in a blueprint anywhere in the map or there is an instance of the class spawned. Every other non class variable works normally.

I know that my savegame contains this class because I opened the file “Slot1.sav” with notepad and saw it there

2 MB test project:

[Google Drive: Sign-in][2]

How to replicate:

  • Open “MapB” and press play. Level blueprint will create a save game and set a class reference actor variable.
  • Open “MapA” and press play. Level blueprint will load the save game and print the actors name on screen.
  • Close and reopen the editor and open only MapA (dont open MapB) and press play. Class wont load and wont print its name on screen.

Up-Voted!

I’m also having this same problem!

I’m trying to load inventory items from a save game slot. If there are currently no references in the level of the class of item I want to load, the class that I try and access from the save slot returns invalid.

This behaviour only happens in standalone games and packaged builds.

Would love to have a fix for this for when 4.14 hits, or a workaround.

It happens in the editor as well. Your editor start up map probably has references on those classes and they stay in memory after you switch map

Yes, you are right.I made my project launch an empty map as default. Closed, re-opened the editor. Clicked play in editor, loaded my save… Nothing… All classes return invalid.

How else are we meant to load classes without a reference to that class?

Hey UE4Hobbyist,

Thanks for the report but it looks like you are missing a step. The documentation here shows how to load a save game and get a value from the SlotName and UserIndex:

https://docs.unrealengine.com/latest/images/Gameplay/SaveGame/Blueprints/LoadGameBP.png

For your project, it would looke like:

This results in:

LogBlueprintUserMessages: [MapA_C_1] Name:TestActor_C

Thank you for submitting a bug report, however at this time we believe that the issue you are describing is not actually a bug with the Unreal Engine, and so we are not able to take any further action on this. If you still believe this may be a bug, please provide steps for us to reproduce the issue, and we will continue our investigation.

Pardon me sir, but I don’t think you understand.

When you load mapB, it creates a save game and sets the class variable to TestActor.

If you close the editor, reopen it on mapA, then play, It loads the save slot that we created before (because the cast succeeds and we get a print out) but the class variable that we saved inside it is null/invalid.

If you don’t close the editor after creating the save from mapB, and go straight into mapA afterwards, the class is valid you get a print out of the class name.

And standalone game just doesn’t work at all, unless there’s already a reference in the level of the class you want to load.

I don’t understand.

Can you follow this and write up a bug report with as much detail, including the steps I need to follow, to see the issue you are talking about?

https://www.unrealengine.com/support/report-a-bug

Just tried to add the “create save game object” node just in case and it makes no difference. Reproduction steps are in the starting question and in Grant Margison comment.

I changed a few things. The first is when you save a variable, the type you are saving should match the type of the variable assigning to. As in, if you save TestActor class, make sure the variable in the Save_Game object is of a type TestActor class.

I also checked the “SaveGame” check box for the variable with flags it as a serializable variable.

Here is the project:

[AH512146][2]

Well, by adding a TestActor class variable, you added a reference of it to the level which is the original problem. You could get the same result by leaving the savegame variable as an actor and putting an empty TestActor class variable anywhere in the level.

In other words, is UE4 unable to save inherited actors?

I understand now. I am debugging to figure out exactly why it’s an issue. I will update you with what I find.

Hello,

Thanks for the report. I was able to recreate the issue and have submitted a issue report for it. You can follow it here:

https://issues.unrealengine.com/issue/UE-37774

The issue seems to only happen when referencing Blueprint Class types. I think this is because of how Blueprint classes are generated, causing an issue when loading the save game slot after the editor has restarted.