How do I create an efficient biome detection system with minimal loops?
I have two weirdly shaped biome borders that change in size randomly. (Like one part can be 50 studs and the part right next to it can be 5) So the info I got from here isn’t too helpful.
You could try raycasting down in a circular array around the player on a fixed radius, and checking what biome each ray strikes, then doing percentage calculations based on the number of rays that strike each biome. This would give you more of an estimate than a concrete number though.
But how would I check what biome the ray landed? Sorry the post is so long. I wanted to get as much information in it as I can. Thanks in advance to anyone that helps.
I would recommend just using volume shapes instead of excessive raycasting because it is likely more performant than the resolution you’d want with raycasting. That suggestion was given assuming the developer needed to be able to blend ambience dynamically between multiple large adjacent biomes. If you don’t need this kind of behavior, and blending fully into one ambience or the next is sufficient, I would recommend just using volumes.
These would have to be statically placed by the developer, or generated once and then registered however.
I’m currently experimenting with this in my own game. I use a “priority stack” to track which biome a player is currently active in, so you can have overlapping volumes, and cave volumes within biome volumes.
Filling the map with parts removes the entire point of biome borders. The biomes are gonna be huge and I dont want to just place parts all day. All though I do like how it works and it could be used for smaller thinks like towns or houses
Mark the areas you want with Parts
Then name all the parts as you want (Forests ,Deserts, Beaches Etc… ) and put them in ReplicatedStorage
And then check the Position of the player if he is inside one of these parts.
You probably don’t need to be super precise with them. You probably want them to overlap a bit off the landmass in-fact, or it would be super jarring to the player to switch into another ambience so quickly.
These are my zones, they are very rough but you generally cannot tell as a player: