|
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
(comments are locked)
|
|
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. Note
(comments are locked)
|
|
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
(comments are locked)
|
