I want to have 1 array per level in a savegame that stores the players location every so often to essentially create a ghost to race against. The problem I’m running into is how to store multiple arrays AND be able to call/modify a specific one depending on the level.
So far it seems structs are my best option for this, but they don’t have a simple way to get a specific index within the struct.
So the problem is that unlike many systems, Blueprint does not allow nesting arrays, strangely. Nesting arrays would definitely be the solution here, typically, but we’re going to have to be a little creative in the execution here.
One thing you could do is just separate them out within the savegame using categories, naming them appropriately for each level, storing them in the GameInstance and then when you load the level, Set the “Current GhostData” in your level by referencing the GameInstance? Does that make sense?
Manually calling the correct array from my savegame in something like the level blueprint would absolutely work, I was just hoping for a more scalable solution lol.
Being able to place a single blueprint in a level and just switch an integer to pull the proper index from a nested array was what I was originally setting out to do, but as you said you can’t really nest arrays.
Worst case I can make your suggestion work, I was just really hoping to not do that haha
I had thought about maps as well, and my original post was actually going to be suggesting that, UNTIL I realized that you can’t use an array as the value portion of the map as you can in other languages such as python.
So I realized, mapping them won’t be incredibly helpful, either. They are always going to need to be in order anyway, so creating the Array one value at a time as the player drives works out. The location doesn’t need a name, just a position, so index works fine.
That’s how I came to the conclusion having them load into a vector array variable on the level seemed to be the best course.
(Not trying to be contrarian, just trying to explain my thought process and how it got there.)
My solution last time i had a similar situation was to create an array that stored identifiers for all the other arrays and then fetched those identifiers when i needed them.
In a lot of cases one big map will do the job just as well since it’s easy to organize, not sure how it might be performance wise though, if a really big map takes a long time for everytime you use the find command or if it’s really quick.