Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Saving objects in Save Game

It seems you can't simply save an object reference.

I have an array of objects; an inventory. The array type is a base class for items, the actual instances are healthpotions, weapons, or whatever.

Of course, I want the inventory to be saved in the saved games and then loaded back. But I don't know how you're supposed to do it, since i can't save objects (can i?).

What's the best way (or just a way) of saving something like that?

Product Version: UE 4.8
more ▼

asked Aug 18 '15 at 06:28 PM in Blueprint Scripting

avatar image

227 6 98 21

avatar image Dadlord36 May 16 '16 at 12:07 PM

I also would like to save my widgets. Whole HUD, like my Inventory with all my Items in it, or just separate Items. Items are just widgets with Images and some references and variables like int, string and some structures like LinerColor.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

i ended up just making a structure, in which i save the class of the item and the number of them (an item can also represent a stack of items, like multiple health potions in one slot).

i get the class via get class, on the actor. oh yeah, the items are actors. this is important, because in blueprints you can't just instantiate arbitrary classes from blueprints.

i then added an array of that structure in my saved game. on loading, i use spawn actor from class with the loaded class for each item.

don't really like this system. for example if i had an item that's more complex, it would be difficult to get that to work. like a weapon that has weapon modifications on it or whatever.

there seems to be a sort of "archive" thing that can - if i understood that correctly - only be used from C++. seems like that can serialize things properly and that's what the SaveGame-checkbox on variables is for.

is that correct, or can that type of serialization be used from blueprints?

more ▼

answered Aug 27 '15 at 09:58 PM

avatar image

227 6 98 21

avatar image marsonmao Jun 15 '16 at 10:40 AM

too bad you have to spawn it yourself...the save system should handle it for you...

avatar image paradoc Jun 30 '16 at 05:41 PM

i'm in the process of trying to save game objects as well, and ran across this thread. you can create objects based on a class that don't have to be actors. for example, if you create a custom blueprint that just extends 'object' class to hold a bunch of information, you can do that. then in another blueprint, to create an instance of that object, just use the 'construct object from class' node. this may or may not help your situation, but working with structs in blueprints can cause mayhem, so sometimes custom objects derived from object class are an alternative (since a class is basically a type of struct anyhow).

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question