public void Particles() { ResponsiveParticles p = Instantiate(particles, transform.position, transform.rotation); p.SetColor(particleColor); Destroy(gameObject); }
void FixedUpdate() { prevPos = transform.position; transform.position = MousePos(); RaycastHit[] hits = Physics.RaycastAll(new Ray(prevPos, (transform.position - prevPos).normalized), (transform.position - prevPos).magnitude); for (int i = 0; i < hits.Length; i++) { if (hits[i].collider.gameObject.GetComponent <Enemy>()) { hits[i].collider.gameObject.GetComponent <Enemy>().Die(); ResponsiveParticles p = Instantiate(particles, transform.position, transform.rotation); p.SetColor(particleColor); } } }