NavMeshAgent.destination  //  寻路的目标点

NavMeshAgent.remainingDistance  //  距离目标点的距离;



//    鼠标点击那里 物体运动到那里的脚本

//  物体要有Nav Mesh Agent 组件


// 地形需要设置成静态的  之后 在navigation  中 BAKE



NavMeshAgent nav;
   
    
    // Use this for initialization
    void Start () {
        nav = this.GetComponent<NavMeshAgent>();
        player = GameObject.Find("Player");
    }
    
    // Update is called once per frame
    void Update () {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray,out hit))
            {
                nav.destination =hit.point;
            }

            
        }
    }



Logo

欢迎加入 MCP 技术社区!与志同道合者携手前行,一同解锁 MCP 技术的无限可能!

更多推荐