random obj. spawn on terrain, avoid defined areas
Hello I'm a 3d Artist and try to make my first game. I'm still learning C# & unity. My problem: I want to spawn objects (stones, small trees) on random locations on my terrain. I found this script and it worked well: [text][1] [1]: http://forum.brackeys.com/thread/random-objects/
The problem is that i have a vulcane and water on my terrain and i don't want to spawn objects in this areas. My thought was that maybe i could use my navmesh as spawnable area, but i don't know if this is possible. Any ideas/solutions about my problem?
Thank you in advance for your help.
you could check each point against the areas you don't want them to appear and if they do generate again. like a circular area would just be a distance check towards the center. rectangle, compare x and z values...
Good idea! But sounds very complexe when i have multiple ponds& streams, a river and the vulcane on a 1000x1000 terrain. Especially when my terrain isn't finished yet and every time i want to change something on the terrain i also have to change the code. Is it possible to define the areas with triggers? So i have a visualization of the areas and change them manually?
Answer by toshibahan · Feb 17, 2017 at 11:49 AM
我建议你可以先放一些点,再在这些点周围随机位置出来,这样会更容易控制随机点的位置范围 I suggest that you can put some points first and then at these points around the random position out,it will be easier to control the random point of the location range
Answer by VoiD_AUT · Feb 22, 2017 at 09:13 AM
Thank you very much. I needed some time for tweaking but finally it works. :-D I created the points with some empty objects and attached the spawn scripts on them.
Your answer
Follow this Question
Related Questions
Tree chopping 1 Answer
A good way to draw a lot of lines (3d grid)? 2 Answers
Diamond Square Algorithm Problems 0 Answers
How do I get better Perlin Noise? 2 Answers
Random object placing parameters 0 Answers