I added basic attack animations to my character controller.
Swinging the sword felt empty. Games I’ve played always had that afterimage trail effect when swinging fast.
Implementation
Generate a mesh along the sword’s trajectory.
Draw a texture on the mesh and push it with a shader. The timing needs to follow right behind the sword’s path.
To sync the timing, adjust the shader texture Offset while watching the sword in the animation.
After searching for how animation stores shader texture values, I found Material._MainTex_ST.
Now I can control shader values through animation.
Tip: Set the shader texture mode to Clamp instead of Wrap. Otherwise the texture keeps repeating. With Clamp, it extends the last pixel seamlessly.
Basic sword trail effect done. Next step: make it 3D and add more options for fancier effects.
Extra Tip
When keying the animation, use the Broken tangent option to prevent the texture from visibly snapping back to the start when the attack animation ends.