I’m curious about how to make lightning travel along a rigged spring, or really any kind of scrolling with flipbook animation (maybe some animated ghosts scrolling across a mesh?).
My approach is to create a ribbon mesh with UVs laid out in a narrow row. The UVs scroll along x to move the texture, and scroll along y to change the flipbook sprite
What this looks like on a UV panning shader. Slowed down the x scroll to see what’s happening, and I still have to figure out how to make the vertical scroll go by flipbook index rather than a smooth pan:
However a drawback with this approach is that especially for long ribbons or higher frame rate spritesheet/flipbooks, the texture size has to be giant compared to the resolution of the image. Is there a better way to have an animated flipbook pan across a mesh or animated motion path?
ribbon UV space = use the full range, (full vertical)
set the texture the same way, do not have empty wasted texture memory along the width
set the texture properties to clamp, not wrap. ensure your end pixels are empty so no visual smears forever
set textures repeats length (UV) to something like 15 so that it only occupies 1/15 of the mesh length, and make sure the start UV offset is -.06 or .06 or .94 or -.94 (whatever pushes it back to the start position on your mesh)
set texture repeats height (UV) to 0.1 and this ensures only 1/10 your texture is used on the height to display only 1 of the sprites
the Y calculation needs to take time (integer) or rounding, posterized, something to make it discard decimals. using multiplies you can adjust time before and after the rounding to control flipbook speed
if you need the flipbook to repeat you can Frac time to use decimal, and then do a (mult) (round) (mult) to control speed
or Wrap Mode
Select how the Texture behaves when tiled. Per-axis Choose this to individually control how Unity wraps Textures at the U axis and V axis.