Delete All Trees under Y

Hi all,

Any chance of removing all trees from a terrain under a specific height?

This would allow us to use the Mass Plant Trees without having to spend 30 mins removing the underwater trees each time.

Cheers

Jeff

pseudo code:

trees = find gameobjects with tag "tree"
for each tree in trees
if tree.transform.position.y < minimumHeight
destroy(tree)

:stuck_out_tongue: Hope you can figure it out!

thanks :slight_smile:

So are the trees placed with mass plat trees all tagged with “Tree”?

Cheers

Ha, good question! I don’t know :slight_smile: I have not yet worked with Unity3d’s terrain tools so I now realize that this might not be your solution.

I do know that with the tree tool you must assign a game object to it, that gameobject can have a tag when it’s a prefab, right?
Also, the destroying will only happen at run time, not in the editor. Possibly a problem?

Yeah destroying at runtime should be fine.

Does anyone know if it’s possible to access terrain data via scripts to delete some trees?

Thanks

Hi all,

Just wanted to bump this post to see if anyone knows of a way to remove all trees below a certain height? I need to remove all trees below the waterline.

Thanks

Jeff

I tried adding a script to my sycamore with collider. The tree now has the script attached but it seems that I can’t get it to be destroyed or even use the print function on a script when it’s attached to the terrain.