Jump to content

How to make trees spawn with more distance between them?


Recommended Posts

I have a spawner that spawns a few different types of trees. I just can't figure out how to get them to spawn more spaced apart. For the most part they are spaced apart decently, but evey now and then they spawn very close to each other, and that's not what I desire.


In an older version (3.2.6) I saw a screenshot with a Bounds Check on the spawn rules, which is maybe what I need? But on 3.3.0 I don't see this option anywhere.


I'm new to the tool, so it's probably something I'm doing wrong, but how can I set it so that trees respect some distance from each other?


Link to comment
Share on other sites

Look at Location increment, and Fitness min max.  , be sure to mouse over, those, it will explain that involves spawning in areas, and location of the GO that your spawning...  


also make sure self check is on if something is spawning on top of one another. 


So for example, say you had 100 pro, location increment was about 5  jitter at 0.


Min fitness was about 25- 90 bounds radius at about 40, self check is on..  I use this when I build citys and I want buildings, near one another, now this can depend on object maps, and so forth.  but to give you an idea.



You also should get warnings, saying you may get a object colliding near one another.  if that happens you can adjust the fitness, which is the areas


For location increment, when you use smaller values, it will spawn more but this can depend on your fitness.   So I tend to use smaller location increments, when I want objects spaced out nicely like a building for example. 


Fitness uses with in the avg bounds area of a game object. 


Link to comment
Share on other sites

Thanks for the information!


I understand better how increment, fitness, and jitter play a role here.


Two things I still am unsure about are where the settings for self check and bounds are located?


I attached a picture of what my spawner looks like. I just don't see those settings on there.



Link to comment
Share on other sites

The screenshot you see there is with a Collision Mask set up with Radius Tree selected. I had this set as a global mask for this spawner, so it's not in the screenshot I posted. No matter what integer value I entered as a radius they would self-intersect and totally ignore it.


If i clicked "Refresh" I could see circles cut into the mask (around all of the spawned trees), but while spawning the Collision Mask did nothing to prevent them from spawning right on top of each other.

Link to comment
Share on other sites

Thanks, I did try this, but inevitably the trees will still intersect in some cases.


Is it correct that there's no guaranteed way to prevent them from spawning too close to each other? We just have to tweak settings and hope they end up not intersecting?

Link to comment
Share on other sites

Hi @iNSiPiD1, there is multiple aspects to this, I hope I can clarify a bit:


  • When spawning a single tree in a single spawn rule, you can usually choose such a location increment and jitter value so that the trees never touch, e.g. if setting a location increment = 50 with 0 jitter gives you a grid like placement with 100% guaranteed no collisions:


This is very stiff and unnatural obviously, so by adding jitter to it you can make the position a bit more varied. By keeping the Jitter below 50% you can avoid two instances colliding with each other because even if two instances happen to jitter "towards each other" they would just be able to meet in the middle of the location increment.



Usually you can find a good compromise between jitter and location increment for the tree type you are using. The collision mask does not know about the trees that are added by the same spawn rule during spawning as it would be to expensive to constantly re-evaluate the masks after every tree being spawned.


  • When adding another tree spawn rule, it does not know about the previously spawned trees, unless you add in a collision mask, this mask will then be evaluated before the second rule spawns and avoid the trees from the first rule this way. Ideally you can make an universal collision mask for all the tree rules in the spawner and put it on top of the spawner as you did already. Did you double check after a tree spawn if the trees show up in the collision mask correctly? You can test this by activating the visualization, it should show you the "holes" cut out by the already existing trees. 

  • I could imagine that you have a bit harder time with your setup since your trees seem to have a broader base and long roots which makes collisions less forgiving than two trees only touching at their branches a bit. If the above is not enough, you could consider the following two workarounds:

    1. You could set up a spawn rule with relatively high location increment and low jitter, then duplicate that rule (the button with the big + on the spawn rule header) which would translate to running the same rule twice - but since the collision mask would be updated inbetween, you might have an easier time to get a good density with 100% no collisions going rather than tweaking the location increment + jitter on a single rule

    2. If that does not work for you either you could consider spawning the trees as game objects instead. The game object spawn rules have those advanced settings for self collision checks that you were mentioning in your earlier post:


    when attempting to put down a new instance, Gaia will check if a previous instance touches the "Bounds Radius" when "Self Collision Check" is enabled. This allows you to put a very low location increment (which would scan for a lot of possible locations than a higher increment would) but still avoiding collisions within the same spawn rule through the self collision check.
    Spawning as Game Objects might result in a little lower performance, but would in turn also allow you better control over the trees such as using a mesh collider which might be attractive for the big roots on your trees as well. 
Link to comment
Share on other sites

Peter, thank you so much for this very well-written and clear explanation. This clears a NUMBER of things up for me that I wasn't understanding, but it makes much more sense to me now.


I currently use Nature Renderer to render the trees in my game. I think that has a dependency that they are placed as trees on the terrain?


I like your idea about using a real mesh collider on the trees, I'm just wondering if I'd lose the benefit of using Nature Renderer if I go that route. Something to think about 🙂

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

  • Create New...