查看: 1424|回复: 0
打印 上一主题 下一主题

[红蓝3D] (转)自动判断路径障碍的寻路功能_代码

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-6-15 17:42:02 |只看该作者 |倒序浏览



   

     
    void Update () {

     
            Ray ray = camera.ScreenPointToRay(target.position);



        



/*Physics.Raycast 光线投射

static function Raycast (origin : Vector3, direction : Vector3, distance : float = Mathf.Infinity, layerMask : int = kDefaultRaycastLayers) : bool

        origin:射线的起始点 direction:射线的方向。 distance:射线的长度  layerMask:只选定Layermask层内的碰撞器,其它层内碰撞器忽略。(注意仔细看截图,发现mask的值为Default,walls 意思就是说路径中只考虑Default,walls可能对路径的影响)*/

        

     



   

     
      if (Physics.Raycast(controler.transform.position, target.position, 1000F, mask))

     
            {

     
                    //Start a path from the unit(s) to the target position

     
                    if (units.Length > 0)

     
                    {

     
                        for (int i = 0; i < units.Length; i++)

     
                        {

     
                            //Call the seeker script to start a path to the target

     
                            units.StartPath(units.transform.position, target.position);

     
                        }

     
                    }

     
                    else

     
                    {

     
                    //从A——>BitStream进行移动

     
                        controler.StartPath(controler.transform.position, target.position);

     
                    }

     
             }

     
        }



分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-23 12:16 , Processed in 0.148445 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部