Unity3D编程学习 小知识_人物移动导航_2018Oct

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

上一篇:ios 下防止整个网页滑动(阻尼回弹 . 瞒天过海,骗IOS,把阻尼回弹限制在滚动区div内


下一篇:手淘H5移动端适配方案flexible源码分析