zoukankan      html  css  js  c++  java
  • unity3d 随机添加树木

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

    随机生成树木

    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

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

  • 相关阅读:
    vim的一些基本配置
    做菜好吃的小技巧02
    SQLServer创建用户登录
    Python库整理
    centos7开机界面出现多个选项
    Elasticsearch和MongoDB简要对比
    OLTP与OLAP
    CentOS7命令总结
    windows下快速删除命令
    Idea配置热部署
  • 原文地址:https://www.cnblogs.com/AnAng/p/8470898.html
Copyright © 2011-2022 走看看