Godot Version
4.1.2
I’m having an error that the truth is that I don’t understand the enemy that I made when he dies outside the plant area it plays the death animation but when he dies in the plant area it doesn’t play the death animation and I really don’t understand the error All this happened when I deactivated the hitbox in the death animations. “Plant” is a node that the enemy heads towards and attacks. code:
@export var movement_speed = 65
@onready var planta = get_tree().get_first_node_in_group("planta")
@onready var sprite = $Sprite2D
@onready var vida = 35
@onready var flash = $hitflash
func _physics_process(_delta):
if is_instance_valid(planta):
var direction = global_position.direction_to(planta.global_position)
velocity = direction*movement_speed
move_and_slide()
if direction.x > 0:
sprite.flip_h = false
elif direction.x < 0:
sprite.flip_h = true
else:
planta = get_tree().get_first_node_in_group("planta")
move_and_slide()
func _ready():
$lil.play("move")
func _on_area_2d_area_entered(_area):
if _area.is_in_group("planta_area"):
$lil.play("attack")
elif _area.is_in_group("bala"):
flash.play("hit_flash")
vida -= 9
if vida <= 0:
set_physics_process(false)
$lil.play("ded")
await get_tree().create_timer(0.8).timeout
queue_free()
func _on_area_2d_area_exited(_area):
if _area.is_in_group("planta_area"):
$lil.play("move")````