terrain.AddTreeInstance() does not generate collider
When I use the following code I get random tree instances on my terrain, but the trees do not have colliders. I need them to have colliders (the prefabs have them attached).
/****
* code which creates the tree prototypes
****/
m_treeProtoTypes = new TreePrototype[2];
m_treeProtoTypes[0] = new TreePrototype();
m_treeProtoTypes [0].prefab = m_tree0;
m_treeProtoTypes [1] = new TreePrototype ();
m_treeProtoTypes[1].prefab = m_tree1;
terrain.terrainData.treePrototypes = m_treeProtoTypes;
/***
* looped code to calculate normative coordiantes and pseudo-random locations
***/
TreeInstance temp = new TreeInstance();
temp.position = new Vector3(normX,ht,normZ);
temp.prototypeIndex = Random.Range (0, 2);
temp.widthScale = 1f;
temp.heightScale = 1f;
temp.color = Color.white;
temp.lightmapColor = Color.white;
terrain.AddTreeInstance(temp);
If I substitute the AddTreeInstance() with Instantiate() code instead I get the colliders, but it is harder to control location because it is not normalized to the terrain. Am I missing something in regard to AddTreeInstance() in order to get the colliders to work?
Your answer
Follow this Question
Related Questions
how to set the SetAlphamaps to one certain texture? 0 Answers
Can't Change The Smoothness of Terrain Layers 0 Answers
Raycasting to tree instances 0 Answers
Terrain Layers cannot be populated at the same time as the splats 3 Answers
How to modify a Terrain at runtime and get back to original Terrain on exit? 2 Answers