# Need help with 2D sprite animations on particles!

Hello!
I am trying to have 2D animated sprites as particles, when they are born the particle texture is on frame one and then play the animation in a linear fashion. Right now this is the best I’ve mastered:

For that test I only animated my particle object’s uv. But they are all having the same animation. I have tried to use the billboard particles, but the tutorials and documentation are not for Cycles, and very outdated, so I have yet to figure out how to use them.
Any help is much appreciated!

Thanks
/Axel

Hi

You could use some maths to convert the UV to extract a different area of a sprite sheet
The U coordinate could then be combined with the {scaled} age of the particle
So as the particle gets older, the U increases in steps, selecting a different area of the sprite sheet
Hopefully you can zoom in on the node setup on the example
e.g.

Best of luck

Martin

Wow! Thanks a bunch, Martin!
Now it’s really starting to behave the way I want it to. But would you mind explaining what numbers to tweak depending on how many frames of animation I have. I’ve just kept tweaking the “Modulo” node until it at least didn’t show any particles with two frames in it. But now I keep getting particles that only change every other frame, isntead of each frame. Would you mind explaining how to figure that out?

Huge thanks!
/Axel

Hi Axel,

You are nearly there, the modulo value is the value you need to change.
The idea is to set this value so it matches the lifespan of the particle against the sprite sheet position.
I assume you want to have one sprite per frame
The short answer is if the lifespan of the particles is N frames and you have N sprites
The modulo value is 1/(N+1)

Because …

The lifespan of the particle in frames is equal to the number of sprites, say N
e.g. if the lifespan is 9 frames and there are 9 sprites each 100 pixels long, then the image texture is 1000 pixels long
0 to 99, 100 to 199, … 900 to 999

The ‘U’ value for a texture varies from 0 to 1
Therefore each sprite takes up 1/(N+1) of the length of the sprite image texture
Each sprite starts at 0/(N+1) 1/(N+1) 2/(N+1) … N/N+1
e.g. in the sprite sheet above the U values would be
0.0, 0.1 … 0.9

The unwrapped mesh needs to cover the first single sprite
So the U value for each particle extracted has the range from 0 to just less than 1/(N+1)
e.g. in the sprite sheet above for the first sprite
0 to <0.1, 0.1 to <0.2 … 0.9 to <1

Therefore the U value for each particle is the U value of the particle 0 to <1/(N+1)
Plus a step for each 0/(N+1) 1/(N+1) … N/(N+1)

To get the step we use the age of the particle / lifespan which ranges from 0 to 1
Minus the particle/lifespan modulo (N+1)

I hope this makes sense!

Martin

PS. The N+1 is important, without the +1 you’ll find there are frames where one sprite is repeated

PPS. An example …

Thank you, Martin!
Everything now animated properly thanks to you, I really appreciate all the help you’ve given me. (:
Here’s the current test result:

But now I can spot small black artifacts in the particles, would you know why that is? I do have an emission shader so might be that, I’ll just have to pick it apart to see what could be the culprit.

My problem now is figuring out how to animate the particle emit on and off, this seemed like a harder feat than I thought since I cannot animate the lifetime. If you wouldn’t mind, and I know you’ve already helped me greatly, do you have any idea how to animate the emit rate?

Huge thanks
/Axel

Hi Axel,

Maybe the black artifacts are due to the transparency in the texture, and not having enough transmission paths set?
I think that if the ray has to go through too many transparent materials it eventually just stops
You’ll find the option under the scene in ‘light paths’
Worth a try.

Animating the particle emission is tricky.
The best thing to try is the guillotine method.
Here you have an invisible {I made it visible in the example} object that kills the particles that are emitted.
Then you animate this object to interupt the particle stream and reduce the flow.
You can try different shapes to moderate the flow as best suits
Make it much closer to the emitter than my example
And have the particle invisible for a couple of frames when it could die

In the picture above the guillotine raises to let more particles through

And then descends again to reduce the flow

Hope this helps

Martin

Thanks again, Martin!
Wouldn’t this solution be very hard to use in the example video I posted with the skull emitting the particles? I tried to use a texture to animate the emit rate, but it is very finicky and often leads to the object not emitting anything. But could that solution work, if set up correctly?

/Axel

Here’s a little update with two tests I did of animated textures on particles:

Thanks again for all the help!

Hi Dunder.

could you upload Sprite particles test v01 blend file?