Instantiated terrain tree collision not working

Hello all!

I’m trying to make a game that loads prefab terrains at run time, triggered by various conditions (such as where the player camera is). I noticed that if I “preload” the terrain (meaning the terrain is already in the scene when game starts as opposed to instantiating prefab), then the tree collision and terrain collision are both working.

However if I instantiate the terrain prefab during run time, terrain collision works but tree collision doesn’t. The way I test it is by moving a rigidbody gameobject with AddForce command, and let it fly towards the tree. The object simply passes through the tree but will bounce upon touching the terrain.

Is this a known issue?

Thanks! :slight_smile:

I figured it out. When you instantiate the terrain, you need to reset the terrain collider like this:

		newTerrain.collider.enabled = false;
		newTerrain.collider.enabled = true;

And then the tree colliders will be generated. Hope Unity puts this in the documentation one day!