zoukankan      html  css  js  c++  java
  • Unity学习记录 导航

    vs 智能提示开关:

    选择External Tools,将External Script Editor选项改为Visual Studio

    1、将导航地图和障碍物 的设置为navigation static,记得要 blake 

    2、给player 添加 NavMeshAgent 组件

    3、通过组件获得主角,

    agent = GetComponent<NavMeshAgent>();

    4、射线获得点击点

            // 1为右键
            if (Input.GetMouseButtonDown(1))
            {
                //射线
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                // 此处使用碰撞处理,可以获得所有的点击“导航范围内”物体对应的坐标
                bool res = Physics.Raycast(ray, out hit,100f);
                if (res)
                {
                    agent.SetDestination(hit.point);
                }
            }

    C# 书写还是很舒服的。

  • 相关阅读:
    【leetcode】第一个只出现一次的字符
    【leetcode】0~n1中缺失的数字
    054696
    053695
    053694
    053693
    053692
    053691
    053690
    053689
  • 原文地址:https://www.cnblogs.com/mitang/p/15712991.html
Copyright © 2011-2022 走看看