How to animate a projectile "shockwave" trail

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By karltha

I wasn’t exactly sure how to describe this because it’s not quite a shockwave. But you see it often with different weapons and abilities in Castlevania games like these examples. It’s easy enough to get the projectile animation working, but I’m struggling to get that neat “trailing” effect as they move across the ground. I’m guessing it might work similar to an animated ghost trail for dashing, etc. that’s also very common in those games, but starting about halfway through the projectile’s animation and not transparent or anything?

EDIT: After looking closer and thinking about this a little more, I don’t think it’s just an animated trail. The trails can typically still do damage, so I think it’s more like each projectile spawns another instance of flames or whatever behind it at a set distance around halfway through its animation cycle.

as you instance() the bullet at the scene
instance an animation scene (shockwave scene) to the bullet scene as well
set x position relative to floor (animation scene (shockwave scene))
Add code to the animation scene(shockwave scene). Delete when animation ends (queue_free())
instance the (shockwave scene) one after the other.

sorry i use Google Translate

ramazan | 2022-09-08 22:16

:bust_in_silhouette: Reply From: SnapCracklins

You could just build it into the spritesheet itself (the entire wave, using Aseprite or Pixelorama) and then call queue_free() whenever the animation ends. But I am guessing you want the projectile’s collision to reflect this as well. (of course you could just move the collision shape)

But instancing is what you’re looking for, as Ramazan suggested. Create one object of a single “piece” of the wave with a collision box and have it free itself whenever its animation ends as it creates other instances of itself until the sequence is done. You’ll want to play with it a bit, which you’ll want to do to get good at animating anyways.

Thanks for the advice! After reading the answers and thinking it over a bit I think it shouldn’t be too difficult to pull off. I think you could probably even have a variable that it increments every time it spawns a copy so you could control the length of the wave.

karltha | 2022-09-09 20:27

Also now that I think of it as a side question, what would be the most efficient way to get an instance to spawn a copy of itself? I see there’s a duplicate() function, but I’m not sure if that’s what I need to be looking at.

karltha | 2022-09-10 02:41

‘Duplicate()’ is for copying arrays. You can just ‘add_child’ after using ‘instance()’ in the code.

SnapCracklins | 2022-09-10 15:20