Random Tree Generation

So I have trees that need to be randomly generated in a specified area. I got that working, but since my landscape is an island and there is a variation in elevation, some trees aren’t on the ground.


How do I fix this in blueprints?

isn’t the foliage tool created for these things ?

Yes but the trees are not just there, they are blueprints so you can cut it down and I dont think that the foliage tool would put down blueprints?..

You could do a line trace straight down from above the landscape using the random x and y values and set the location of the static mesh to the hit location.

I’m not too advanced at using blueprints. How would I do this?

See if this helps, I did this last night and worked exactly how I wanted it for me. So I am getting the Tree object which you already have and doing a line trace by channel. I have set the start line trace position be the (Tree location Z - 200) because the origin of the tree was in the centre so when the line trace was happening it was always hitting the tree mesh. Then I set the end location of the line trace to be the (Tree’s location Z - 1440) You might need to change the values to suit your tree mesh.

Then on the “On Hit” output of the LineTraceByChannel node, if you drag out from that and type ‘break’ you can get the break the hit result and check what Actor is Hit, so I’m checking to see if the Actor has a tag “Landscape” (There’s probably better ways to check its the floor that’s being hit) then get the location and store that in a local variable called "Landscape Location and set the Tree Location to the Landscape Location with an offset on the Z. Mine is 100 but you will need to change it to suit your trees so they are flush.

Hope I explained this well enough and this helps!

Edit: To set the tag of an actor, open its blueprint and search “Tag” in the details panel on the right and add a tag there, call it whatever you want but make sure the blueprint node has the same tag name.

I’m not too advanced at using blueprints. How would I do this?
[/QUOTE]

This is pretty much the same as what said, but here’s what I would do:


Just add in the ‘Actor Has Tag’ and ‘branch’ nodes like how said to make sure the trees only spawn on the landscape :wink:

Thanks! That seems to work just fine!