Tree collision

Hi,

I can’t get the tree collision to work. I’m using a player controller and the move function and collision is working fine against static meshes and against some capsules that I’m using. But even if we can see the tree colliders (capsules) in the prefab it won’t work when in game. Any ideas?

//ohm

Select your terrain and make sure that “Create tree colliders” is checked in the properties tab.

You must put your tree in a new prefab and make a collider for it.I think capsule collider is use full for this.

The “Create Tree Colliders” checkbox is checked. We are loading the terrain from script with code locking something like this:

TerrainData terrainData = (TerrainData)Resources.Load(path, typeof(TerrainData));
GameObject terrain = Terrain.CreateTerrainGameObject(terrainData);

Would that matter?

//ohm

This is how we are doing:

  1. Create new prefab
  2. Setup mesh, materials and stuff
  3. Add capsule collider
  4. Use as a tree in the terrain editor

What have I missed? Should I make one prefab with just the mesh and then another based on that one with a collider?

//ohm

that’s right.

we discovered if you programatically alter the location of the terrain the tree colliders no longer work… if the trees were created when the terrain was at 0,0,0 and the terrain remains at 0,0,0 they work otherwise you have to move the terrain THEN create the trees. Moving the terrain after the trees are created will turn off the colliders (perhaps they retain their original location …i dunno)