x

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"

Adding an array of variables into actors in the world

Hi there, I'm making a save and load system where the game saves variables of a parent actor and adds the variables of its children into an array that is then saved. Once it is saved it then loads and puts the variables back where I want them, I am using structs and a struct array.

I am able to get the game to save and load fine but with one major issue, that being the variables aren't loading into the correct actors. What I have at the moment is... alt text This gets the actors in the world which currently is 2 actors. So for each loop it gets the array that I had saved and sets the information residing at that index into that actors struct variable.

This isn't precise and the code doesn't know which struct info to add to which actor. Does anyone know how I can tell it which actor to give which struct variable? Sorry if this is confusing let me know if you need any more info. Thanks!

Product Version: UE 4.16
Tags:
capture.png (116.3 kB)
more ▼

asked Jul 19 '17 at 10:14 PM in Blueprint Scripting

avatar image

LewisEKay
3 1 3

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

2 answers: sort voted first

Thanks to unit23 I got the idea to give each actor its own specific ID. I made an array of the parent class. Then using a for each loop node I could input all actors in the scene into that array at a specific index. That index would relate to a number I gave each child which I set as a new integer variable for each child created. So the code knows where each actor is in the array. Thanks for the help! alt text

1.png (95.9 kB)
2.png (148.7 kB)
more ▼

answered Jul 20 '17 at 01:45 AM

avatar image

LewisEKay
3 1 3

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

This blueprint shows how to set player IDs (in multiplayer, may offer some ideas), https://forums.unrealengine.com/showthread.php?150238-Proper-architecture-for-updating-a-UI-in-a-lobby-system&p=738291&viewfull=1#post738291

Before the loop i would set the actor class array up, then make a break (when right clicking the exit node of the class array variable) from that, which includes all class actor variables. Then work from there, with your loop.

Basically each actor needs a unique ID, which could be related to a unique actor tag.

For each loop get ID (via break), branch then from that ID, and add the code required for each ID. If you have more than 10 it will become kind of messy with many nodes, but currently have no other idea. Maybe make actor groups which share the same setup, those class actors can be setup via your game mode default settings too, (when you set this code up inside your custom gamemode blueprint, and add classes). So if you have like 5 actor class arrays, those could have each their own child customizations, explained in this video around the 3 min mark https://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gbY4FN8pZuEPVC9PzQThNn1/OVrfHO2DdOs/index.html

more ▼

answered Jul 19 '17 at 10:30 PM

avatar image

unit23
488 30 45 81

(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