How to make a top-down random tree generator?

I am making a top-down “multiplayer survival game” and I need a generator that places trees in random positions within the map. and I have no idea how to do so, can someone help me?

didn’t you do this before or was that not randomly genrated
can you send me the game.

I did it on a 2d format.
This is top down.
image
Top down
image
2D

maybe make it so the middle is randomly placed and the sides spawn around it

You could spawn them randomly off grass blocks.

Its a top down, there are no grass blocks

you can use the random behavior to set the range of where things can spawn. this is the code behind some of the special effects spawning in parse-o-rhythm - your numbers will be different but its the same idea.

It worked, but now I need it so there can be a certain # of trees in the world, to avoid crashing.

I will get you a screenshot. :slight_smile:

I think this will work; (I did not test it yet.)

2 Likes

This should make it so trees will spawn randomly, but not to much?

1 Like

That random that goes into the ‘count’ in the reapeator, is the min/max amount of trees spawning.

I really like the way this is laid out! it should work :slight_smile:

2 Likes

Thanks! I wanted to make sure it was really easy to read and understand. :slight_smile:

1 Like

Quick note, the “Done” output is connected to the Y Random, it should be the “Out” output (otherwise only 1 tree will spawn)
The “Number” spawning the trees also isn’t needed, the bottom Random can directly connect to it (unless you specifically wanted a Starting value of 1)
Same with the Repeater, you don’t really need a Timer as the starting input, the Random setting the Count can also activate it

1 Like

This is what the code did…
image

1 Like

My game crashed lol

Increase the values in the Random behavior, otherwise it’s10 pixels

If the game crashed, check how many you’re spawning in

1 Like

Oh, your right. Sorry, I coded it really quick. :slight_smile:

I just solved my own problem, thank you all for the help!

1 Like