Unity3D自带寻路学习笔记

1新建一个Cube 设置大小(10,0.5,10),重命名plane;在plane上新建3个cube改名obstacle;新建一个sphere,和一个cube 分别重命名为player,target。Hierarchy面板如下图所示 Unity3D自带寻路学习笔记
 2 Window>Navigation打开Naviagtion面板,选中3个obstacle设置如下图:
Unity3D自带寻路学习笔记

  选中plane设置如下图:
Unity3D自带寻路学习笔记


3 新建一个C#脚本,如下:
  1. public class NavTest : MonoBehaviour
  2. {
  3. public Transform target;
  4. private NavMeshAgent navMeshAgent;

  5. void Start ()
  6. {
  7. navMeshAgent =GetComponent<NavMeshAgent> ();
  8. }

  9. void Update ()
  10. {
  11. navMeshAgent.destination = target.position;
  12. }
  13. }
4为player添加component>Naviagtion>NavMesh Agent组件,并把脚本挂在player上;NavMesh Walkable层为Deault,target拖拽到NavTest中的Target 设置如下图:
Unity3D自带寻路学习笔记


5调整障碍物,和目标物体的位置,让其看起来很舒服,如下图所示^_^:
Unity3D自带寻路学习笔记


6打开Navigation面板下Bake子面板设置一些参数,参数的解释看手册,点击Bake,然后Ctrl+P简单的寻路就OK了。



The NavMesh Agent component is used in connection with pathfinding, and is the place to put information about how this agent navigates the NavMesh. You can access it in Component->Navigation->Nav Mesh Agent

导航网格代理(NavMesh Agent )组件用于寻路,是存放代理如何在导航网格(NavMesh)中导航的信息的地方。你可以在Component->Navigation->Nav Mesh Agent访问。

导航网格代理(NavMesh Agent )组件用于寻路

  • Radius 半径
    Agent radius (used for pathfinding purposes only, and can differ from the actual object's radius, typically larger).
    代理的半径(仅用于寻路目的,可以跟实际对象的半径大小不一样,一般比实际对象的半径大)。
  • Speed 速度
    Maximum movement speed with which the agent can traverse the world toward its destination.
    代理可以周游世界,走向它的目的地的最大移动速度。
  • Acceleration 加速度
    Maximum acceleration. 最大加速度。
  • Angular Speed 角速度
    Maximum rotation speed in (deg/s). 最高转速(度/秒)。
  • Stopping distance
    制动距离
    Stopping distance. The agent will decelerate when within this distance to the destination.
    制动距离。到目的地的距离小于这个值,代理减速。
  • Auto Traverse OffMesh Link
    自动遍历OffMesh链接
    Automate movement onto and off of OffMeshLinks.
    自动移动并关闭OffMeshLinks
  • Auto Repath 自动重新寻路
    Acquire new path if existing is partial or invalid.
    如果现有的部分已失效,获得新的路径。
  • Height 高度
    The height of the agent (used in debug graphics).
    代理的高度(用于调试图形)。
  • Base offset
    基本偏移
    Vertical offset of the collision geometry relative to the actual geometry.
    碰撞几何体相对于实际几何体垂直的偏移。
  • Obstacle Avoidance Type
    障碍躲避类型
    The level of quality of avoidance.
    躲避的质量水平。
  • NavMesh Walkable
    导航网格行走
    Specifies the types of Navmesh layers that the agent can traverse.
    指定代理可以遍历的导航网格层类型。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值