向鼠标点击出移动

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.AI;

public class cubemove : MonoBehaviour {

    public NavMeshAgent aaa;

    Ray ray;

    RaycastHit hit;

void

Start () {

}

    // Update is called once per frame

    void Update()

    {

        if (Input.GetMouseButtonDown(1))

        {

            ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))

            {

                aaa.SetDestination(hit.point);

            }

        }

    }

}


你可能感兴趣的:(向鼠标点击出移动)