The Terrain Collider component exposes a Toggle (Boolean) in the Unity Inspector called “Enable Tree Collider”. Has anyone discovered a way to enable or disable this in a script?
You could simply just get the mother of all colliders and set it to inactive using:
GetComponent().SetActive(false);
How would I know which were the tree colliders that applied to the TreePrototypes in the Unity Terrain? What is the “Enable Tree Collider” option doing behind the scenes?
You ever figure out a method on how to do this? I want to keep distant terrain collider on, but enable tree colliders on close terrain tiles. So performance doesn’t take a massive hit.
Im looking for this too, cant seem to find anything on this.
Unity Terrain is the biggest pain.
- When you create a terrain, you have a terraindata file/component saved to the root of your asset folder. This terrainData is important, and you need to rename it immediately so you don’t forget where it is.
- TerrainData is on TerrainCollider and the actual Terrain component as well.
- It MIGHT be:
terrainCollider.terrainData.treeInstances? No, that’s not it that just sets the positions I guess?
Unfortunately, if Unity hasn’t exposed this value, there’s really nothing any of us can do. Unity Terrain also has some of the worst documentation in the history of Unity API documentation, it’s very vague and you have to figure a lot of stuff out for yourself…
I know it’s kind of a pain, but if you want this kind of funcationality you may be stuck getting a Terrain from the Asset store other than Unity Terrain. Unity Terrain is also expensive to the CPU and GPU if you’re making a mobile game, although they did at Instancing…