惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
D
Docker
J
Java Code Geeks
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
腾讯CDC
罗磊的独立博客
U
Unit 42
爱范儿
爱范儿
Vercel News
Vercel News
MyScale Blog
MyScale Blog

博客园 - 华安

自适应网格系统:CSS Grid中repeat()、auto-fill与auto-fit的深度解析 CSS3中响应式布局两大神器display:flex和display:grid springBoot中的 pom.xml文件 bulid学习 CSS中元素的display显示方式有多种,隐藏、块级、内联、内联-块级 SQl Server 中的 go 是什么作用 CSS中 display:flex的align-items: stretch; 移动端浏览器(尤其是 iOS Safari)的橡皮筋回弹效果(Overscroll / Bounce Effect) 手机端浏览器上ES6中的Fetch回调执行 window.open没效果 用Flex实现兼容性好的全屏布局 在 VS Code 中使用 C# Dev Kit 和 Unity Tools 调试 Unity 2022 Unity 可编程物件(ScriptableObject) 微信小程序中的 联系客服 最基本的使用方法 wx.requestSubscribeMessage(Object object) 和 wx.requestSubscribeDeviceMessage(Object object) 这两个有什么区别 微信小程序中 wx.hideLoading() 后调用 wx.showToast()的问题 Windows 中启动 Nginx的常用命令 CSS进阶技巧:字体渐变、描边、倒影与渐变色描边全解析 netCore 中各DLL引用了 SkiaSharp.dll的问题 unity中预制体解包 在 Unity 中,Time.timeScale实现游戏暂停加速等 微信小程序中关联微信支付 C#中TaskCompletionSource(简称 TCS)学习 Unity 编辑器 中,快捷键 Ctrl + Shift + F 的功能 unity中按下 F键,让物体聚焦 微信中进入定页面的,判断时通过扫二维码进入的,还是点小程序名称进入的 MYSQL中从JSON字符串中提取指定的值 Unity2022中创建动画 Animation(旧方法) Unity 中区别,public 和 [SerializeField] Unity中 onCollisionEnter2D与OnTriggerEnter2D 区别 asp.netCore中给动态请求路径加客户端缓存 netCore中获取客户端真实的IP引起的思考
unity中的 Navigation AI使用
华安 · 2026-08-09 · via 博客园 - 华安

1、在unity中安装 AI Navigation

464e304b-dd2e-449f-8372-82162221eb44

6817e4a2-fc4e-4ba7-a93e-8ba948744ebb

 2、在scene中添加一个Plane,在 Plane中添加一些 Cube用于测试导航。

0f56b0ba-154a-4170-a78f-135b683ca4cf

 3、设置不同的导航模式

fa777e5a-371e-436e-92b8-c3bfcc52414c

cc851ab8-edbb-4a7c-9a4f-12142fec27b7

 4、烘焙不同的导航路径,便于实际中使用。

6f8ccc6c-5b99-4ca4-bc50-3f9da333cb74

 5、添加一个物体,用来测试自动导航。

dd193b41-0c82-4a0f-a87d-2ef38a8f3ed2

 6、PlayerController.cs脚本编写。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class PlayerController : MonoBehaviour
{
    private NavMeshAgent navMeshAgent;
    // Start is called before the first frame update
    void Start()
    {
        //获取代理组件
        navMeshAgent= GetComponent<NavMeshAgent>();
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log(navMeshAgent.isOnNavMesh);
        if (navMeshAgent != null && navMeshAgent.isActiveAndEnabled && navMeshAgent.isOnNavMesh)
        {
            ///获取鼠标左键
            if (Input.GetMouseButton(0))
            {
                //获取点击位置
                Ray ray=Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray,out hit))
                {
                    
                    //点击位置
                    Vector3 vector=hit.point;
                    
                    //设置目标点
                    navMeshAgent.SetDestination(vector);
                }
            }
        }
    }

}

7、把脚本挂在到物体上开始运行项目。

da661ac0-6085-4e3f-8a26-ccc1a259bce7

 大致就是这样子,里面的有些参数细节,可以自己边练习边摸索,反正我也是在摸索。