技能追踪
技能追踪其实就是让粒子系统追着敌人打,也就是移动粒子,要想移动粒子要把一个物体上的粒子全部拿到,然后遍历移动,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
public GameObject A;
private float speed = 50;
private ParticleSystem particle;
private int size;
private ParticleSystem.Particle[] temp;
void Start() {
particle = this.GetComponentInChildren<ParticleSystem>();
temp = new ParticleSystem.Particle[particle.maxParticles];
}
void LateUpdate()
{
size=particle.GetParticles(temp);
float step = speed * Time.deltaTime;
for(int i = 0; i < size; i++)
{
temp[i].position = Vector3.MoveTowards(temp[i].position, A.transform.position, step);
A.transform.position, step);
}
particle.SetParticles(temp,size);
}
}