How can i rotate preloaded scene of AnimatedSprite2D?

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

So, I have a preloaded scene of my muzzle flash for a gun into a gun scene. and playing it through:

func create_muzzle_flash():
var flash_instance = flash.instantiate()
flash_instance.position = bullet_point.get_global_position()
flash_instance.rotation_degrees = bullet_point.rotation_degrees
get_tree().get_root().add_child(flash_instance)
await flash_instance.animation_changed
flash_instance.queue_free()

But it’s a) not rotating correctly and b) after animation finished it litters ground with the last frame of said animation and not deletes it.


What i’m talking about:

(please, someone, help, and % is spaces in browser btw.)
And yes, I need it as a scene, for PointLight2D from the muzzle flash.

:bust_in_silhouette: Reply From: Lucksinia

About rotation. I need to use rotation_degrees of something that actually rotates (Parent scene in my case).
About littering. I added queue.free() at the preloaded scene like this and all worked at the end:

extends AnimatedSprite2D

func _ready():
play("flash")
await animation_finished
set_frame_and_progress(0,0)
queue_free()