- Home /
Question by
Maxdeboer · Jan 29 at 11:12 AM ·
scripting problemsizeparticle collisionlifetime
Size over lifetime and particle collisions
I am creating a fire in Unity and the fire has to spread. So I use OnParticleCollision to see if my fire collides with other objects.
I also use the size over lifetime module to change the size of my fire. It starts small, grows bigger and goes out after some time. Too change the size of my fire I use this code:
int start_X = 0;
int start_Y = 1;
float end_X = 0.50f;
int end_Y = 0;
ParticleSystem part;
ParticleSystem.SizeOverLifetimeModule sz;
ParticleSystem.ShapeModule ps;
AnimationCurve ourCurve;
public void changeSize(float fire_size) {
// print(fire_size);
end_X = fire_size;
part = gameObject.GetComponent<ParticleSystem>();
sz = part.sizeOverLifetime;
AnimationCurve curve = new AnimationCurve();
curve.AddKey(start_X, start_Y);
curve.AddKey(fire_size, end_Y);
sz.size = new ParticleSystem.MinMaxCurve(1.0f, curve);
}
Visually it works. The fire gets bigger and smaller. But while the fire doesn't touch other objects visually it still triggers an OnParticleCollision and sets the other objects on fire. The radius scale of the fire is set to 0.0001 in the Collision module.
Do particles disappear when their size is 0? Do they just become invisible? Is this a correct way to change the size / height of my fire?
schermopname-4.png
(392.9 kB)
Comment