Announcement

Collapse
No announcement yet.

Saving and Loading Multiple Instance of Same Class

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Saving and Loading Multiple Instance of Same Class

    Hey Guys

    I'm struggling a little with the save and load system.

    Basically what I am trying to do is Save the Inventories of all the storage chests I have in a level.

    All of the Storage Chests are just children of a single Master Chest (let's say BP_Storage_Child <-- Multiple instances of this). I have an 'Inventory' component attached to the Master Chest which contains the Struct Array (Storage_Array) which holds all the details for each item.

    So what I want to be able to do is Save the contents of each chest and am not sure how. I know I will need to use 'Get All Actors of Class - BP_Storage_Child' and go from there, but not sure how. I don't suppose anyone can point me in the right direction from here? I am able to successfully save my characters inventory, but that's because there is only 1.

    I am also using the Save Extension Plugin for Unreal which is fine for saving everything else I need, but is unable to do what I'm asking above.

    Thanks.

    #2
    Originally posted by Jimminy_Cricket View Post
    Hey Guys

    I'm struggling a little with the save and load system.

    Basically what I am trying to do is Save the Inventories of all the storage chests I have in a level.

    All of the Storage Chests are just children of a single Master Chest (let's say BP_Storage_Child <-- Multiple instances of this). I have an 'Inventory' component attached to the Master Chest which contains the Struct Array (Storage_Array) which holds all the details for each item.

    So what I want to be able to do is Save the contents of each chest and am not sure how. I know I will need to use 'Get All Actors of Class - BP_Storage_Child' and go from there, but not sure how. I don't suppose anyone can point me in the right direction from here? I am able to successfully save my characters inventory, but that's because there is only 1.

    I am also using the Save Extension Plugin for Unreal which is fine for saving everything else I need, but is unable to do what I'm asking above.

    Thanks.
    It´s preatty simple ..Add a actor array to the save class ..and 1 transform . After every actor of class do a foor loop ...get the position of your actor , add the position to a array of transform . Also add your actor to a actor array. When this is done and stored in the array ..just the other way..take the array..get all of you actors stored in it ..and spawn it again . I will post a link from youtube for this

    https://www.youtube.com/watch?v=UR-g8Zcrq7g&t=1176s

    You Don´t need to follow the hole tutorial . Start where he begin to add the save class varibles . Childs need to be seperated for the transform ..otherwise they will get same location everyone :P ( atleast my path ) ..so child 1 needs to have a transform , child 2 class need to have and so on ...


    Last edited by Jensa86; 06-20-2019, 02:11 PM.

    Comment


      #3
      Hey Jensa, thanks for the reply. I'm not looking to save the transform though as my storage containers will always be in the same location as they are manually placed into the level.

      What i'm trying to do is save the Inventory Array inside each storage container which is a struct array. So basically, if the player adds to the storage container or removes something from the storage container and saves the game, I need it to load up as it was when it was saved.

      What you said and the video you linked help a little, i'm just not sure how I go about saving the Struct Array (Storage Inventory) and Loading it back up.

      Thanks.

      Comment

      Working...
      X