using System; using System.Collections; using System.Collections.Generic; using UnityEngine;using UnityEngine.AI; /// <summary> /// 特效追踪,挂靠在特效物体上面的 /// </summary> public class EffectTracks : MonoBehaviour { /// <summary> /// 攻击目标. /// </summary> private GameObject target; public void SetEnemy(GameObject target) { this.target = target; } void Update() { Debug.DrawLine(target.transform.position , this.transform.position , Color.yellow); transform.rotation = Quaternion.Slerp( transform.rotation , Quaternion.LookRotation(target.transform.position - transform.position) , 2 * Time.deltaTime ); transform.LookAt(target.transform); transform.position += transform.forward * 8 * Time.deltaTime; if (Vector3.Distance(transform.position,target.transform.position)<=1) { Debug.Log("特效到达地方!开始自爆"); } } }
粒子特效追踪敌人 | 拾荒者 http://www.shihuangzhe.org/?p=561
时间: 2024-10-24 19:47:05