Hello everyone,
I am new to Godot and I am reading tutorials and watching youtube videos. I'm currently learning the basics on a small platformer project. Now I have the movement with friction etc. and an enemy who can be stomped on. After that I wanted a vanish animation. But there is the first problem because queue_free () is executed immediately and the animation cannot be seen. However I thought it would be cooler anyway if the opponent falls apart. But now I have absolutely no idea how to code something like this and can't find anything on the Internet.
Here's an example:
Enemy script: extends KinematicBody2D
export var velocity = Vector2(-100, 0)
var gravity = 1500
func _on_StompDetector_body_entered(body):
if body.global_position.y > $StompDetector.global_position.y:
return
$AnimatedSprite.play("dissapear")
queue_free()
func _physics_process(delta):
velocity.y += gravity * delta
if is_on_wall():
velocity.x *= -1
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
velocity.y = move_and_slide(velocity, Vector2.UP).y