寻路的相关参数
需要先勾选 游戏场景中所有需要烘焙路径信息的游戏对象状态为 static
然后点开windos菜单下的navigation窗口进行烘培
Navigation Static ;表示该游戏对象是否参与导航网格的烘培
Generate OffMeshLinks : 是否可以使用OffMeshLinks使不连续的地段连接起来
Navigation Area : 导航区域设置
Agent Radius : 具有代表性的物体半径
Agent Height : 具有代表性的物体的高度
Max Slope : 最大可行进的斜坡斜度
Step Height : 可进行的斜坡高度
Drop Height : 允许的最大下落距离
Jump Distance : 允许的最大跳跃距离
Advanced : 高度参数调节
导航组件的相关参数
Agent Size: 尺寸控制
Radius : 物体的半径
Height : 物体的高度
Base Offset : 偏移值
Steering : 行动控制
Speed : 物体最大行进速度
Angular Speed : 物体的行进过程中转向的角速度
Acceleration : 物体的行进加速度
Stopping Distance: 距离目标点小于多远的距离时,停止移动
Audo Braking : 是否自动制动
Obstacle Avoidance : 躲避障碍物的参数
Quality : 质量
None : 无
Low Quality : 低质量
Medium Quality : 中等质量
Good Quality : 较好的质量
High Quality: 高等质量
Priority : 优先级
Path Finding : 路径寻找
Auto Traverse Off Mesh Link : 是否采用默认的方式渡过连接路径
Auto Repath : 在行进过程中,因某些原因中断的情况下,是否重新开始寻路
Auto Mask : 自动遮罩
动态障碍物
Nav Mesh Obstacle 组件中Carve选项使导航网格会在游戏过程中实时进行烘焙。
Carve选项的属性
Move Threshold 模型移动某个距离后烘焙
Time To Stationary 指定模型在某个位置停止一段时间后在烘焙
Carve One Stationary 勾选后,模型移动时不会实时烘焙
操作第一步:
之前的所有的对障碍物设置的静态属性全部取消勾选
操作第二步:
在障碍物的对象上添加Nav Mesh Obstacle组件
操作第三步:
设置Nav Mesh Obstacle相关属性
Shape属性是对障碍物的外形进行设置
//挂载对象
private NavMeshAgent agent;//Navigation mesh agent 导航网
//桥
public GameObject drawBridage;
public GameObject sphere;
//时间
float timer = 0;
//桥的转向
private int rotateDirection = -1;
// Use this for initialization
void Start()
{
//获得组件
agent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{ //从屏幕获得鼠标的射线
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (Input.GetMouseButtonDown(0))
{
agent.SetDestination(new Vector3(hit.point.x, agent.transform.position.y, hit.point.z));
}
}
//时间间隔
timer += Time.deltaTime;
if (timer > 5)
{// 桥的转动位置和速度
drawBridage.transform.RotateAround(sphere.transform.position, sphere.transform.forward, 10 * rotateDirection * Time.deltaTime);
}
//桥的方向的改变
if (timer > 10)
{
timer = 0;
rotateDirection *= -1;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)