导弹追踪,方法一简单,但效果一般,建议采用方法二。
using UnityEngine;
using System.Collections;
public class AIFollow : MonoBehaviour {
public GameObject man;
public GameObject missile;
public float manSpeed = 6f;
public float missileSpeed = 4f;
public float missileRotateSpeed = 2f;
bool whehterShooted = false;
float distance;
float collisionDistance;
// Use this for initialization
void Start () {
if (man!=null&&missile!=null)
{
float manWidth = man.GetComponent().mesh.bounds.size.x*man.transform.localScale.x;
float missileLength = missile.GetComponent().mesh.bounds.size.z * missile.transform.localScale.z;
print("manWidth:"+manWidth.ToString()+",missileLength:"+missileLength.ToString());
collision