Noeski / September 2023 (71 Words, 1 Minutes)
I’ve been wanting to add a
ghost trail effect to the game engine for a while now and this week I was able to spend some time implementing it.
ghost trail is an effect where we periodically take a snapshot of a character and then tint/fade them out which creates a really nice effect combined with movement.
For sprites this is pretty simple and can be achieved by maintaining a pool of
SpriteRenderer objects and spawning a new one with the current frame of the character when needed. In The Song of Awakening we use Spine to render our characters which makes this effect much more difficult. Rather than a single quad that fades nicely, Spine creates a 3D mesh that may have several areas that overlap which makes transparency very difficult.
In order to fix this we need to create an intermediate render target that we can render the mesh to and then use that render target as our ‘sprite’. Spine actually has some examples of how to do this, but I created a modified version of their
SkeletonRenderTexture that can target any
MeshRenderer and only render a single frame on demand. This intermediate step is much slower than the simple sprite route, but the effect looks quite nice!