Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kyle J144 |
Hi,
I have got a basic scene with an animation and when the animation is finished, then it loads a new scene and when you load back in to the animated scene, the the animation starts again, where as i don’t want it too. I have been trying solution and researching regarding this for just over 2 weeks. I have tried singletons, animation states and even trying with simple code.
Her is my code below:
extends Camera2D
var animation_has_played = false
# Get a reference to the AnimationPlayer, which is a child of the camera.
onready var anim = $AnimationPlayer
func _ready( ):
if not animation_has_played:
$AnimationPlayer.play("camera_auto_move")
animation_has_played = true
else:
remove_child(AnimationPlayer, Camera2D)
func _on_AnimationPlayer_animation_finished(camera_auto_move):
if animation_has_played:
get_tree().change_scene("scenes/missions/prologue/prologue-hallway.tscn")
else:
if animation_has_played:
$AnimationPlayer.play("")
My scene tree is below:
Any help appreciated and thanks in advance