Godot Version
4.3
Question
Ok so I have a death animation in my player scene but i cant figure out how to play it because all the code for the killzone is in a different scene. Here’s the tree for the player scene
player<-- root
playersprite<-- root child
deathanimation<-- playersprite child
dashtimer<-- root child
collisionshape2d<-- root child
and the killzone code
extends Area2D
#variables
@onready var health = 20
@onready var timer = $Timer
@onready var damaged = true
@onready var playeranimation: Timer = $“player animation”
#functions
func _on_body_entered(body: Node2D) → void:
while(damaged):
health -= 1 #<-- subtracts health
damaged = false
timer.start
print(health)
if health <= 0:
health = 0
print("You Died!")
playeranimation.start
#this is where the animation should be
get_tree().reload_current_scene()
elif health <= 10:
print("You Are Hurt.")
else:
print("You Are Fine.")
func _on_timer_timeout() → void:
damaged = true