Version 4.3 stable
I am making a small movement prototype to test out the engine and I took the habit of making each VFX a separate scene so I could instantiate them as needed. This worked flawlessly on my character but now that I am trying to make the checkpoint VFX work, the actual animation only plays on the first area2D trigger and not the second.
For the record, I have simply duplicated the structure for my first checkpoint to make the other ones, code works flawlessly from what I see. Here’s what I have so far.
(Don’t mind the messy structure)
Code on the Area2D
@export var flagGetVFXScene: PackedScene
func _on_area_entered(area: Area2D) -> void:
var parent1 = get_parent()
var parent2 = parent1.get_parent()
var parent3 = parent2.get_parent()
var deathPlane = parent3.get_node("DeathPlane")
var currentFlag
if get_parent() == parent2.get_node("Flag1") and deathPlane.checkpointIndex <= 0:
deathPlane.checkpointIndex = 1
currentFlag = parent2.get_node("Flag1/Area2DFlag")
var flagGetVFX = flagGetVFXScene.instantiate()
flagGetVFX.position = currentFlag.position + Vector2(0, -10)
add_sibling(flagGetVFX)
elif get_parent() == parent2.get_node('Flag2') and deathPlane.checkpointIndex <= 1:
deathPlane.checkpointIndex = 2
currentFlag = parent2.get_node("Flag2/Area2DFlag")
var flagGetVFX = flagGetVFXScene.instantiate()
flagGetVFX.position = currentFlag.global_position + Vector2(0, -10)
print(currentFlag.global_position)
add_sibling(flagGetVFX)
print(deathPlane.checkpointIndex
Code on the animatedSprite2D
extends AnimatedSprite2D
func _on_frame_changed():
print(frame)
func _on_animation_finished():
queue_free()
The animationSprite2D has autoplay checked and loop unchecked
Any ideas for why it is not playing on the second flag?