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 …