//clone a particle that will fade but not move or linger public void layALingerer() { //Instantiate NON-triggerable particle GameObject lingerer = Instantiate(gameObject, transform.position, transform.rotation, lingeringParent.transform); //prevent feedback loop lingerer.GetComponent <Collider2D>().isTrigger = false; lingerer.GetComponent <Rigidbody2D>().simulated = false; //isKinematic? SonarParticleController pc = lingerer.GetComponent <SonarParticleController>(); //everything else should be the same, e.g. faderT (the most important) pc.velocity = Vector3.zero; pc.lingerLaying = false; //this could use.... tweaking pc.timeToFade = (timeToFade - faderT) * lingerRate; pc.faderT = 0; }
void Start() { sonarParticles = new List <GameObject>(); float angleIncrement = (endAngle - startAngle) / particleResolution; for (float curAngle = startAngle; curAngle < endAngle; curAngle += angleIncrement) { GameObject newParticle = Instantiate(sonarParticle, gameObject.transform.position, Quaternion.identity, gameObject.transform) as GameObject; SonarParticleController pc = newParticle.GetComponent <SonarParticleController>(); Vector3 dir = Quaternion.AngleAxis(curAngle, Vector3.forward) * Vector3.right; pc.light.spotAngle = particleSpotlightAngle; pc.timeToFade = timeToFadeOut; pc.velocity = speed * dir; pc.color = color; pc.lingerInterval = lingerInterval; pc.lingeringParent = lingeringParent; pc.lingerInterval = lingerInterval; pc.lingerRate = lingerRate; pc.intensity = intensity; sonarParticles.Add(newParticle); } }