- 最后登录
- 2017-5-15
- 注册时间
- 2012-3-1
- 阅读权限
- 90
- 积分
- 32973
  
- 纳金币
- 32806
- 精华
- 12
|
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);
}
}
}
|
|