<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>VFX on GameSweetGame</title><link>https://gamesweetgame.com/en/tags/vfx/</link><description>Recent content in VFX on GameSweetGame</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 21 Feb 2025 00:00:00 +0900</lastBuildDate><atom:link href="https://gamesweetgame.com/en/tags/vfx/index.xml" rel="self" type="application/rss+xml"/><item><title>Unity Sword Trail Effect</title><link>https://gamesweetgame.com/en/p/unity-sword-trail-effect/</link><pubDate>Fri, 21 Feb 2025 00:00:00 +0900</pubDate><guid>https://gamesweetgame.com/en/p/unity-sword-trail-effect/</guid><description>&lt;p&gt;I added basic attack animations to my character controller.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Basic attack" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px"&gt;&lt;/p&gt;
&lt;p&gt;Swinging the sword felt empty. Games I&amp;rsquo;ve played always had that afterimage trail effect when swinging fast.&lt;/p&gt;
&lt;h2 id="implementation"&gt;Implementation
&lt;/h2&gt;&lt;p&gt;Generate a mesh along the sword&amp;rsquo;s trajectory.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Sword trajectory as mesh" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px"&gt;&lt;/p&gt;
&lt;p&gt;Draw a texture on the mesh and push it with a shader. The timing needs to follow right behind the sword&amp;rsquo;s path.&lt;/p&gt;
&lt;p&gt;To sync the timing, adjust the shader texture Offset while watching the sword in the animation.&lt;/p&gt;
&lt;p&gt;After searching for how animation stores shader texture values, I found &lt;code&gt;Material._MainTex_ST&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now I can control shader values through animation.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Sword trail texture following the blade" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px"&gt;&lt;/p&gt;

 &lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Set the shader texture mode to &lt;strong&gt;Clamp&lt;/strong&gt; instead of Wrap. Otherwise the texture keeps repeating. With Clamp, it extends the last pixel seamlessly.&lt;/p&gt;

 &lt;/blockquote&gt;
&lt;p&gt;&lt;img alt="Final result" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px"&gt;&lt;/p&gt;
&lt;p&gt;Basic sword trail effect done. Next step: make it 3D and add more options for fancier effects.&lt;/p&gt;
&lt;h3 id="extra-tip"&gt;Extra Tip
&lt;/h3&gt;&lt;p&gt;&lt;img alt="Broken option" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px"&gt;&lt;/p&gt;
&lt;p&gt;When keying the animation, use the &lt;strong&gt;Broken&lt;/strong&gt; tangent option to prevent the texture from visibly snapping back to the start when the attack animation ends.&lt;/p&gt;</description></item></channel></rss>