- Home /
Unity tree colliders acting very strange
I mass placed plenty of trees on my terrain game object, all tree prefabs had !isTrigger colliders and were in the default layer. The terrain collider component also has Enable Tree Colliders set to true. For some reason the colliders are not working, however. The player can walk straight through them and they are not being detected by any raycasts.
What's very strange is; if I disable and re-enable the terrain collider component at run time, the colliders suddenly become detected. For example, the code below makes the tree colliders work correctly.
TerrainCollider col = hit.transform.GetComponentInParent<TerrainCollider>();
if (col.enabled)
{
col.enabled = false;
col.enabled = true;
}
This is a temporary fix to my problem, but does anyone know what is going on here?
Your answer
Follow this Question
Related Questions
How can i get terrain data from Terrain.asset? 0 Answers
how do i use height map data for use in coding? 0 Answers
[SOLVED] Unity 5 - Runtime Terrain Deformation Collider Bug 4 Answers
Terrain data was not recognize and want to solve. 1 Answer
Object2Terrain Creates a Invalid Collider. Help please. 1 Answer