I have a particle system and I want to control the velocity of emitted particles. I can modify the emission speed of new particles, but I want to also adjust the velocity of particles that already exist. I assumed I could do that by getting the particles, updating the velocities and setting the particles again, but when I then check the velocities the next frame, they’re unchanged.
Here’s the code:
void LateUpdate()
{
if (mUpdateParticleSpeed)
{
mUpdateParticleSpeed = false;
// Update particle velocities, assumes constant velocity
int numParticles = particleSystem.particleCount;
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[numParticles];
particleSystem.GetParticles(particles);
for (int i = 0; i < particles.Length; i++)
{
var particle = particles*;*
_ particle.velocity = particle.velocity.normalized * mParticleSpeed;_
-
}*
-
particleSystem.SetParticles(particles, numParticles);*
-
}*
-
}*
Any suggestions as to the problem? I’ll post an update if I figure it out myself.
Thanks.