Creating trail in Godot

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

Hey all, in this new game I am creating, I have a moving kinematicbody2d with a sprite( a red dot) attached. Is there any way I can create a trail behind the kinematicbody2d?

I couldn’t find anything useful on the internet.

:bust_in_silhouette: Reply From: rustyStriker

You can sort of cheat one, I took a bunch of Sprites and sets their position to the one in front of them every frame, that way you have some sort of a buffer for the later ones. I also changed their alpha channel in the modulate in visibility…

you can make it better by using more Sprites or having an array with a bigger range of delays

Could you provide some kind of code cause I couldn’t get it to work.

SingingApple | 2018-02-22 13:14

func update_ball():
$Ball/Sprite6.global_position = $Ball/Sprite5.global_position
$Ball/Sprite5.global_position = $Ball/Sprite4.global_position
$Ball/Sprite4.global_position = $Ball/Sprite3.global_position
$Ball/Sprite3.global_position = $Ball/Sprite2.global_position
$Ball/Sprite2.global_position = ball_last
ball_last = $Ball.global_position

that is the code i use, the Ball node got 6 sprites on it and there is one buffer added, i update it every frame(would recommend updating every couple frames or something)

rustyStriker | 2018-02-22 18:02