向鼠标点击出移动

2019-01-03  本文已影响0人  咆哮的小老虎

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);

            }

        }

    }

}

上一篇 下一篇

猜你喜欢

热点阅读