void OnTriggerEnter(Collider hit) { if (hasCollided) { return; } if (hit.gameObject.tag == "Slot") { return; } hasCollided = true; //transform.DetachChildren(); impactParticle = Instantiate(impactParticle, transform.position, Quaternion.FromToRotation(Vector3.up, impactNormal)) as GameObject; //Debug.DrawRay(hit.contacts[0].point, hit.contacts[0].normal * 1, Color.yellow); if (hit.gameObject.tag == "Destructible") // Projectile will destroy objects tagged as Destructible { Destroy(hit.gameObject); } else { BaseProjectile proj = GetComponent <BaseProjectile>(); //Check if we should splash if (proj) { proj.ApplyEffects(); } } //yield WaitForSeconds (0.05); foreach (GameObject trail in trailParticles) { GameObject curTrail = transform.Find(projectileParticle.name + "/" + trail.name).gameObject; curTrail.transform.parent = null; Destroy(curTrail, 3f); } Destroy(projectileParticle, 3f); Destroy(impactParticle, 5f); Destroy(gameObject); //projectileParticle.Stop(); ParticleSystem[] trails = GetComponentsInChildren <ParticleSystem>(); //Component at [0] is that of the parent i.e. this object (if there is any) for (int i = 1; i < trails.Length; i++) { ParticleSystem trail = trails[i]; if (!trail.gameObject.name.Contains("Trail")) { continue; } trail.transform.SetParent(null); Destroy(trail.gameObject, 2); } }