- Home /
Particle System Emission Rate Scriptt
Hello all,
So I'm currently having trouble with adjusting the emission rate. Ive searched a good bit but its hard sorting out whats part of the old methods and the new. Here is my current script.
private ParticleSystem nps, rps;
void Start () {
// initialize the rigidbody of the current object
rb = GetComponent<Rigidbody>();
// initialize the particle systems
nps = normParticles.GetComponent<ParticleSystem>();
rps = revParticles.GetComponent<ParticleSystem>();
// adjust scale based on mass
AdjustScale();
startingMass = rb.mass;
}
public void AdjustScale()
{
// adjust scale of object based on mass
s = rb.mass / 10;
transform.localScale = new Vector3(s, s, s);
// adjust the normal gravity particle system to match scale
ParticleSystem.ShapeModule nsm = nps.shape;
nsm.radius = s * 2f;
ParticleSystem.EmissionModule nem = nps.emission;
nem.rateOverTime = 2f;
Debug.Log("rateovertime: " + nem.rateOverTime);
ParticleSystem.MainModule nmm = nps.main;
nmm.startSpeed = (s / 3) * -1;
nmm.startLifetime = s / 10;
}
So first off, when i tried using the script example out of the API i wasn't able to get anything to work. The other modules have very similar scripts to adjust. With my current script based off other unity answers and examples, i can adjust the radius, startSpeed, and startLifetime of my particle system but i can't seem to adjust the rate over time. It automatically reverts to 5 regardless of what my script has.
edit: forgot to mention that the debug log prints out the following for the rate: rateovertime: UnityEngine.ParticleSystem+MinMaxCurve
i tried playing with setting the constant max and constant min with no success.