Topic was automatically imported from the old Question2Answer platform.
Asked By
Diet Estus
I am trying to implement a trail effect on my sprite during certain states, similar to what you see below:
As pointed out in the answer below, there is a helpful discussion of this effect using Particles2D, in the documentation, but it doesn’t answer all my questions.
It seems like the documentation tutorial uses a static image for the texture of the trailing particle. My sprite uses an AnimationPlayer. How do I go about using the previous or current frame of the animation as the particle texture? I may also need to change the orientation of the particle to reflect the orientation of my sprite (i.e. flip it left or right).
I tried using:
texture = player.get_node("Sprite").texture
in my Particles2D node, but it assigned the particle my entire spritesheet, rather than the current frame of it.
Here it is, an example from the docs. If you have a doubt about it, feel free to ask it!
It seems like that tutorial uses a static image for the texture of the trailing particle. My sprite uses an AnimationPlayer. How do I go about using the previous or current frame of the animation as the particle texture? I may also need to change the orientation of the particle to reflect the orientation of my sprite (i.e. flip it left or right).
Diet Estus | 2018-03-17 19:59
I tried using:
texture = player.get_node("Sprite").texture
in my Particles2D node, but it assigned the particle my entire spritesheet, rather than the current frame of it.
Diet Estus | 2018-03-18 02:54
Any idea? I’m sure it’s simple, just can’t figure it out.
Diet Estus | 2018-03-20 20:17
The docs are showing a static texture. It doesn’t show how to make it update as the main sprite updates.
I just figured a bit silly way to address this in AnimatedSprite since I just encountered the same problem, not sure if it will work for your AnimationPlayer.
The trick is to create as same number of animations as sprites, or frame you have, then load different sprite textures one by one into in each trail. Now you have one animation for one trail.
Then, in the script, you use “$Trail.emitting = true/false” to enable different trails you want to have in a certain moment. Remember to disable the rest completely and save the one you want to the display, and you could make if functions or for loop to make different conditions for which to frame of trail to display.