- Home /
How to store references of generated objects
Hello,
In my code I generate a grid of objects with Instantiate but I don't know how to keep reference of each of them by their coordinates (I rely on int coordinates to keep things simple). At first I looked at GameObject[,] but for that I need to know the maximum size my "map" would become and I don't have that information as it is infinite as it's generated as the player moves. Another limitation I found about GameObject[,] is that I can't store negative indexes, so I would not be able to use to store x and y values inside it.
What do you suggest me to use?
Thank you.
Answer by VesuvianPrime · Dec 11, 2014 at 10:49 PM
Take a look at games like Minecraft where the world is made up of fixed "chunks" which are loaded as the player moves.
You're not going to be able to make a game where objects travel far from the origin as you start to get rounding issues.
Your answer
Follow this Question
Related Questions
How to set to game objects's position from 2 different game objects arrays equal to each other? 0 Answers
What is the best way to instatiate an array of connected GameObjects? 0 Answers
How can i get ONLY the childrens of a GameOnbject with GetComponentsInChildren method? 5 Answers
Read different game objects into array at same time? 2 Answers