Saving actors inside level

(i’ve edited my previous post btw).
inheritance is a really basic concept, so you’ll benefit from learning it.
it’s super easy. you just create a bp child of actor, and put a name to it.
then open your actors, there’s a button for class settings, then change the parent actor. that’s it.

check some docs, it will pay off.

inheritance is much more powerful than interfaces on some places. and i use it way way more.

though now that i think about it, you might still need to store that info on the savegame.
so you might still need to add a struct to keep the data.

so i would do this:

  • create a struct for saved data with fields : id, position, interacted. MyStruct
  • on the base class have a function GetSavedData, returns the struct MyStruct, filled.
  • also have a function GetId
  • also a function LoadData with a MyStruct as param

in the game state:

  • the code you have now will be pretty similar. but you can use getallactorsofclass, which i think it’s even faster than withinterface (since it implements buckets, wereas withinterface does not yet (afaik)).
  • when saving you iterate all objects, get id, get that from the saved map, if it exists, you call Object->LoadData(struct)
  • when loading you iterate all objects, get id, call GetSavedData(), store the struct in the map with the id.
  • you store a map with the id as key, and mystruct as value.