What are the ways to create this script?

I need to make a script for my game that is going to spawn trees on the map. There will be different maps that include uneven terrain, water and rocks that trees cannot spawn on. The trees themselves are all of different size and models, but have the same primary part on the bottom of the trunk. What are some ways that I could create such an algorithm?

I was thinking of maybe somehow using raycasts but I’d like to know if there are better ways of going about this before I actually start work on it.

1 Like

Ray cast are the best way to do this. They are very optimized and you can fire dozens if not hundreds per frame without performance issues.

You should raycast from above ground downwards and decide if you want to place a tree or not.

here’s something I found that might help:
https://devforum.roblox.com/t/tree-spawning-at-terrain-y-level/400911

1 Like