Animation control shuriken particle emission ?

Hi All,
I have a gameobject A
gameobject A have an animation call “myAnimation” and a particle call “myParticle”

In Animation Window I add keyframe for myParticle to enabled and disable emission because I want to control “myParticle” emission when “myAnimation” runs .

Example : when “myAnimation” runs to frame 30 “myParticle” will emit , frame 31 “myParticle” will stop emit , frame 42 “myParticle” will emit , frame 43 “myParticle” will stop emit…

I have a problem that particle is not working like I expect , it means animation can not control particle emission . Is it right or wrong ? Can anybody here help me how to control the emission of particle when “myAnimation” is running ?

Thanks for reading.

This should be possible without problems if you either script the animation or use the emission module.

For scripting use ParticleSystem.Play and ParticleSystem.Stop and proper yield WaitForSeconds() statements (it’s better to be frame rate independant). If you only want small bursts of particles like in your example you could use ParticleSystem.Emit(). See the docs for additional details Unity - Scripting API: ParticleSystem.

Alternately the shuriken particle system can also be controlled by the emission module. This is quite simple to do but only works if you don’t want want to change the loop during runtime. This is most likely the easiest way to achieve what you want. Corresponding doc: Unity - Manual: Particle System modules.

However controlling a particle system through animation should be possible as well by setting a curve for the emission module but I would not recommend this. Setting up such a curve is troublesome since the values should only be 0 or 1. Thus for a longer animation you get a long and thin line which is quite hard to handle.

@Lockstep : Thanks so much for your answer.

So there is no way to control particle’s emission by using key frame in animation ?

This is easy doable with Animation Events and a bit scripting.
Add an Animation Event at the desired frame at your AnimationClip and call a function that starts the particles.