I am creating a simulation of a solar system (all procedurally generated)
Whilst the game is running it’s fine it’s not jumpy or anything, my issue is creating asteroids…
I have roughly 1500-4000 asteroids but they are generated in one go at the beginning. I am using a script that allows me to change the Frequency, gain etc… of the asteroid, but In reality I only need to create 30-50 asteroids instantiate the mesh, texture and shader alone.
What would be the best way to go about doing this so it doesn’t have to generate thousands of asteroids?
Also, if there are any other tips please feel free, a small solar system can be between 1GB - 2GB in memory when building, and in reality i really don’t need it to be close to that.
My Current thinking is to make a list of 50 asteroids that have been generated, access that mesh, texture and shader somehow and instantiate that with random scaling? or because it still has to hold that mesh, texture and shader will it still be heavy?
I’m not the best at unity or at getting my point out ha…
Create some sort of AsteroidManager(int count). The AsteroidManager can then create a certain amount and pool them. When you need to destroy one it will just disable it rather than actually destroying it. As far as spawning goes…I suggest NOT spawning everything at once (unless it needs to happen) and do it over the course of a couple of frames. Using an IEnumerator can achieve this.
I currently have an Asteroid Manager, that manages all the interactions they do, thus far none of them get destroyed, the update of them isn’t the issue.
I am working on a university project, trying to get a procedural generation solar system working. I feel I have gotten pretty far, just working on the rulesets i need to apply to everything to get the correct data now.
Sorry i felt i needed to explain what i’m doing so the generation is going from nothing to something, so it is all generated at ones.
I will look into the enumeration, as that will probably get things on the screen, would it increase load time or just show that it’s doing something though?
As i was saying a big part of the memory issue is this script that generates the land is generating a new big of land each time and instantiating it, Is there no way to sort of point at one that already exists and just use that ones model? that way it might not be producing as many models?
I just Implemented IEnumerators… wow that is amazing what it can do to increase load times!
Eeesh, cheers for that i might have to use them a bit more haha.
Sorry for the late response was in class when I replied to this. Yeah IEnumerators does chunks of computations over time rather than everything all at once. So it can make loading things a whole lot faster to boost performance especially when it comes to generating things at runtime. Glad it helped!