I'm trying to remove trees dynamically.
I can remove the visible mesh/tree with TerrainData.treeInstances.RemoveAt(n) But I'm stuck with the colliders of the destroyed trees.
I've run out of ideas. Any one have a solution for this? Is it possible?2
asked Mar 09 '10 at 11:11 PM
I'm surprised that RemoveAt works at all for you with the treeInstances array, since it's a built-in array and doesnt' (as far as I know) support the RemoveAt function.
When I have modified or set the treeInstances array in the past, I've always built or modified them in a variable sized array (such as an ArrayList or List), and then dumped the entire new array back into terrainData.treeInstances as a whole, like this:
And also, make sure you are calling:
after modifying the tree instances array.
answered Apr 14 '10 at 02:26 PM
Here is how:
You also may need to disable and reenable the terrain collider.
Here is a thread that gives more details: http://forum.unity3d.com/threads/110354-Finally-Removing-trees-AND-the-colliders
Sounds kind of like a bug. Try submitting a bug report.
answered Mar 30 '10 at 09:55 PM