- Home /
Best way to save the postition of 800+ GameObjects?
Hey peoples.
Basically the title says it all, what would be the best way to save the position of everything in the game world? I currently have the player position and stats saving and loading but I don't know how to approche the gameobjects.
Cheers.
How would you identify these objects? Do they have something in common? The same tag or parent would work, but I'd need to know before giving an useless answer :)
They are in groups of tags, i have aranged those groups of tags into parents. So all the ones with the same tags now have the same parent.
Answer by Craze · Apr 28, 2011 at 03:09 PM
There are multiple ways to approach an issue like this.
A) Do it the super easy way, save it ALL as a single prefab and create it when you need it. This however has its downsides and it is going to be the same every single time.
B) Another method is to save your positions into a set of 2d arrays, which can be complex, but potentially useful.
C) (A method I am using right now) You can generate grid patterns by using a set of for loops that create objects with a certain distance between rows and columns. This method however is only useful for creating grids.
D) A method that is a mix of A) and B), which is to save the entire environment as a collection of organized prefabs and then use code to spawn them as you need them.
These options are how I would deal with such challenges, but undoubtedly there are smarter ways people have devised.
D) Is the most logical usually, because you can cut down on the massive lag caused by spawning a huge area of objects. $$anonymous$$aking 800+ objects all one prefab will generate a massive amount of lag upon creating it(Hence it's downsides).
Good job writing a will thought out and correct answer. +1!!!
Your answer
Follow this Question
Related Questions
Save data from one scene to another? 0 Answers
Serializing a graph 2 Answers
Problem about reading and writing from text files 1 Answer
Retrieving basic Strings and Ints from XML Files (JS) 0 Answers