Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to create a trailing, ghosting like effect of a sprite that's moving fast. Something very similar to this image of Sonic (apologies of bad quality, it's the only example I could find of the effect I'm looking to achieve)

Ghost trail

However, I don't want to do this at the sprite sheet level, to avoid having to essentially double (or possibly quadruple) the amount of sprites in my atlas. It's also very labor intensive.

So is there any other way to achieve this effect? Possibly by some shader voodoo magic? I am using Unity and 2D Toolkit, if that helps.

share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

You could easily do this with a particle system and a shader. Set up the particle system to release 1 particle every X milliseconds with a max of 3 particles. (Choose an X based on how far apart you want the trailing sprites to be.) For the particle, use the same image as the character's current sprite, but with a different material. Try some of the alpha blended shaders on the material to get the effect that you want on the trailing particles.

If you want to get fancier, you could adjust the max # of particles and other settings based on the character's current speed.

Here is an example that I was able to do with just 1 Quad, 1 sprite, 2 materials, and a particle system.

I attached the particle system to the Quad and set the quad to use the Sonic sprite. I'm using only the Emission, Color over Life time, and Renderer settings of the Particle System.

Max particles: 5

Simulation Space: World

Start Lifetime: 1

Start Speed: 0

Color over lifetime: Fade from White (Alpha 255) to Black (Alpha 0)

Renderer Material: Using same image as the original, but with "Particles/Alpha Blended" shader.

Sonic with Trailing Particle Effect

share|improve this answer
    
This works perfectly. The only thing I need to work out is how to programmatically set the material on the particle system renderer to match the current sprite image (again, I'm using 2D Toolkit so it's different from Unity's sprite system). –  Neeko 13 hours ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.