//ClickMove - - 通过鼠标点击控制物体移动 using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI; // include NavMeshAgent public class ClickMove : MonoBehaviour { public NavMeshAgent player; //获取动画组件
//public Animator anim; // Use this for initialization
void Start () { } // Update is called once per frame
void Update () { if(Input.GetMouseButtonDown())
{
//通过鼠标点击的位置生成射线
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray,out hit))
{
print(hit.point);
player.SetDestination(hit.point); //转递鼠标点击信息
}
} //控制动画的播放
//anim.SetFloat("Speed", player.velocity.magnitude); }
}
ClickMove - - 通过鼠标点击控制物体移动