开放世界随机地图才是最重要的..

随机生成树木

Terrain.terrainData //获取地形设置

terrainData.treePrototypes  {get;set;} //获取或设置树木列表

{

GameObject prefab//树木实例

float bendFactor//设置大于0

}

terrainData.treeInstances {get;set;} //获取或设置地形上的树木

TreeInstance{

Vector3 position //树木位置

float widthScale //宽度大小

float heightScale //高度大小

float rotation //旋转y轴

Color32 color //大概的颜色

Color32 lightmapColor //不知道是什么鬼,反正我是设置白色,如有知道请留言 多谢

int prototypeIndex //对应树木所在索引

} 

设置好后执行

terrainData.RefreshPrototypes();

  

2018-3-12

补充

新添加好的树木测试发现没有碰撞体,API完全没有提示 懵逼中

最后还是在百度上找到了

 TerrainCollider tc = ATerrain.GetComponent<TerrainCollider>();
        tc.enabled = false;
        tc.enabled = true;

  居然要重新加载一次,完全没有想到..

来至:http://blog.sina.com.cn/s/blog_471132920101fzod.html

里面介绍非常详细,受益匪浅。

相关文章:

  • 2021-04-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
猜你喜欢
  • 2021-04-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-10-12
相关资源
相似解决方案