sinbad / SPUD

Steve's Persistent Unreal Data library
MIT License
336 stars 51 forks source link

Player character data is saved only on level #61

Closed caspiDoron closed 1 year ago

caspiDoron commented 1 year ago

Currently the player character data is being saved only on the current level. when I travel to a new level the data would not be loaded and the default values would be set. if I would go back to the previous level I would see the correct values. For example the current ammo the character has...

Is there a way to exclude the player character class to be updated on every spawn? Thank you and good job on this awesome plugin!

sinbad commented 1 year ago

Did you implement OverrideName as the docs mention? https://github.com/sinbad/SPUD#gameplay-framework-spawned-actors

caspiDoron commented 1 year ago

Yes, before I had warning to implement it so I did… UE version 5.2

sinbad commented 1 year ago

OK so the issue is that when travelling to another level your character is re-created by the GameFramework. You don't have a choice in this (barring seamless travel but even that tends to re-create things IME). SPUD isn't doing anything with it at that point because there isn't any data to load from the new level. So it's not a case of SPUD re-initialising your character, it's that your character is naturally blank anyway. And when you revisit each level, actor state is going to be restored to what it was when you exited that level, which isn't what you want for a character which is supposed to be a single instance travelling across levels (but actually exists separately in each level because of how UE works).

Any data you want to keep persistent across levels should really be in something that is not destroyed & re-created during level transitions and not on the character. I suggest a data structure in a GameInstance or GameInstanceSubsystem. You can then register that as a global object in SPUD so that its state is preserved across saves.

caspiDoron commented 1 year ago

Thanks! That’s what I thought. I just saw that the data is being load on the level it was so I figured maybe I could tell it to load it on all levels instead of changing the logic.