Unity-NaviMesh

1.对我们的可寻路场景物体进行Navagition的烘焙(Bake),可寻路的物体我们将它设置为静态(static),我们在Areas中设置要bake的物体为什么区域,修改权重(Cost)。 2.给物体添加NavMeshAgent 3.添加脚本,引入UnityEngine.AI命名空间

    private NavMeshAgent navMeshAgent;

    public float speed;
    public Transform Target;

    private void Awake()
    {
        navMeshAgent = GetComponent<NavMeshAgent>();
        navMeshAgent.speed = speed;
    }

    private void Start()
    {
        navMeshAgent.SetDestination(Target.position);

    }

OffMeshLink:

Link allowing movement outside the planar navigation mesh. OffMeshLink component allows you to incorporate navigation shortcuts which cannot be represented using a walkable surface. For example, jumping over a ditch or a fence, or opening a door before walking through it, can all be described as Off-mesh links. Tips: 有小圆圈说明成功创建了

OffMesh.PNG

Areas 在Navigation中添加新的Areas

Areas.PNG

NavMeshObstacle: 在场景中添加动态的障碍物 将场景中新产生的物体设置为寻路中的障碍,默认网格不会重新烘焙,勾选Carve之后会make a cut-out in the navmesh.

A NavMeshObstacle is cylindrical in shape and can move around the surface of the NavMesh with a specified velocity. By default, the obstacle will only affect the agent's avoidance behaviour rather than the pathfinding. This means that the agent will ignore the obstacle when plotting a path but will sidestep around it while moving along the path. If carving is enabled, the obstacle will create a temporary "hole" in the NavMesh. The hole will be recognised by the pathfinding, so paths will be plotted to avoid the obstacle. This means that if, say, an obstacle blocks a narrow gap, the pathfinding will seek an alternative route to the target. Without carving, the agent will head for the gap but won't be able to pass until the obstacle is clear.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Unity-UI(UGUI详解)01基础概念、自动布局、动画集成、富文本

    Canvas应该包含全部UI元素,全部的UI元素应该时Canvas的子物体 调整元素的显示顺序可以从Hierarchy中直接拖拽他们,顺序从也可以被控制通过S...

    祝你万事顺利
  • Unity-UI(UGUI详解)02.2 Interaction组件、Auto Layout

    此类是交互组件的基类 Property: Interactible:组件是否接受输入,当设置为false,组件将不可用 Transition:在可选组件中...

    祝你万事顺利
  • Unity-UGUI

    画布 Canvas 画布是摆放容纳所有的UI元素的区域,所有的UI元素需要在Canvas上组装。 Canvas 组件

    祝你万事顺利
  • SAP S/4HANA生产订单状态含义

    版权声明:本文为博主汪子熙原创文章,未经博主允许不得转载。 https://jerry.bl...

    Jerry Wang
  • 目标检测一波接着一波 | YOLOv5又悄悄来袭!(附源码论文链接)

    期待已久的检测经典又来来了一波强袭——yolov5。其实yolov5没有完整的文件,现在最重要的应该是把yolov4弄清楚,在目标检测领域中受益匪浅,可以在某些...

    计算机视觉研究院
  • 多人部件解析

    Towards Real World Human Parsing: Multiple-Human Parsing in the Wild https://a...

    用户1148525
  • JDBC读取数据优化-fetch size

    最近由于业务上的需求,一张旧表结构中的数据,需要提取出来,根据规则,导入一张新表结构中,开发同学写了一个工具,用于实现新旧结构的transformation,

    bisal
  • 【CodeForces 589F】Gourmet and Banquet(二分+贪心或网络流)

    A gourmet came into the banquet hall, where the cooks suggested n dishes for gue...

    饶文津
  • Android NDK Debug

    前言:说真的Android NDK debug还是推荐lldb,gdb经常莫名其妙的不成功。不过下面的这个流程是谷歌官方建议的,还是有参考价值的。尤其是在App...

    望天
  • hduoj1073--Online Judge

    做道题,并没有太多的技巧,关键在与对Accepted,presented error 和wa的判断,第一步如果两者完全一样,那么很定是AC了 ...

    Gxjun

扫码关注云+社区

领取腾讯云代金券