Godot Version
Godot 4
Question
I Want to Kill my Enemy (snail) by jump pn Top and I tryed A alot and When i Jump ok Top its Only Disapeer do Any one know How To Get The Animation death Befor it Gets out my Screen `
Godot 4
I Want to Kill my Enemy (snail) by jump pn Top and I tryed A alot and When i Jump ok Top its Only Disapeer do Any one know How To Get The Animation death Befor it Gets out my Screen `
can you show your code for your snail?
Chances are, you are calling queue_free before the animation is done playing. What you need to do is to wait till the death animation is done before you queue free.
You need to use the animation_finished
signal before removing the node with queue_free
, which I assume you’re using to make it “disappear”.
func die():
$AnimationPlayer.play("death")
await $AnimationPlayer.animation_finished
queue_free()
I dont Know How To send here pics Can U maybe add me on Discord (Gongikong)
you can copy and paste your code here. just make sure to use the formatting:
you can also try @Troglodyte suggestion
extends Node2D
const SPEED = 60
var direction = 1
var health = 1
@onready var snail: CharacterBody2D = $“.”
@onready var killzone: Area2D = $AnimatedSprite2D/killzone
@onready var timer: Timer = $Timer
@onready var ray_cast_right: RayCast2D = $RayCastRight
@onready var ray_cast_left: RayCast2D = $RayCastLeft
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
func _process(delta):
if health <= 0:
$CollisionShape2D.disabled = true
set_physics_process(false)
else:
# Bewege den Gegner weiter
if ray_cast_right.is_colliding():
direction = -1
animated_sprite.flip_h = false
elif ray_cast_left.is_colliding():
direction = 1
animated_sprite.flip_h = true
position.x += direction * SPEED * delta
func _set_animation():
if direction > 0:
animated_sprite.flip_h = true
elif direction < 0:
animated_sprite.flip_h = false
if health <= 0:
animated_sprite.play(“death”)
func _on_animated_sprite_2d_animation_finished():
if animated_sprite.animation == “death”:
pass
@warning_ignore(“unused_parameter”)
func _on_area_2d_body_entered(body: Node2D) → void:
timer.start()
animated_sprite.play(“death”)
print(“death”)
killzone.queue_free()
animated_sprite.stop()
print(“Schnecke wird entfernt”)
queue_free()
snail.queue_free()
func _on_timer_timeout():
Engine.time_scale = 1.0
if is_instance_valid(killzone):
print(“Killzone wird entfernt”)
killzone.queue_free()
else:
print(“Killzone war bereits entfernt”)
animated_sprite.death()
print(“Schnecke wird entfernt”)
queue_free()
snail.queue_free()
i got it thank u soooo much
i got it