x


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.

more ▼

asked Apr 28 '11 at 01:30 PM

jamie gravatar image

jamie
31 12 12 15

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 :)

Apr 28 '11 at 01:39 PM Joshua

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.

Apr 28 '11 at 08:50 PM jamie
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Apr 28 '11 at 03:09 PM

Craze gravatar image

Craze
88 3 5 11

D) Is the most logical usually, because you can cut down on the massive lag caused by spawning a huge area of objects. Making 800+ objects all one prefab will generate a massive amount of lag upon creating it(Hence it's downsides).

Apr 28 '11 at 03:23 PM Craze

Thanks, D is a great option.

Apr 28 '11 at 08:17 PM jamie

Good job writing a will thought out and correct answer. +1!!!

Apr 29 '11 at 10:21 AM zmar0519

Just happy to help :D

May 04 '11 at 06:50 PM Craze
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Topics:

x297
x133
x110

asked: Apr 28 '11 at 01:30 PM

Seen: 1051 times

Last Updated: Apr 28 '11 at 01:30 PM