标签:physics sep sys inpu ati set mouse red 小知识
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class PlayerMove : MonoBehaviour {
public GameObject myObj;
void Start () {
}
void Update () {
if (Input.GetMouseButtonUp (0)) {
Ray myRay = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (myRay, out hit)) {
if (hit.collider.gameObject.tag == "box") {
Debug.DrawLine (myRay.origin, hit.point, Color.red);
myObj.GetComponent<NavMeshAgent> ().SetDestination (hit.point);
myObj.GetComponent<NavMeshAgent> ().speed = 5;
myObj.GetComponent<NavMeshAgent> ().acceleration = 8;
myObj.GetComponent<NavMeshAgent> ().angularSpeed = 100;
}
}
}
}
}
Unity3D编程学习 小知识_人物移动导航_2018Oct
标签:physics sep sys inpu ati set mouse red 小知识
原文地址:https://www.cnblogs.com/RainPaint/p/9787119.html