add player bounce when killing enemy

This commit is contained in:
2025-10-22 12:33:50 +01:00
parent 4338abab62
commit bfefcffb1f
2 changed files with 7 additions and 1 deletions

View File

@@ -271,6 +271,7 @@ animation_player = NodePath("../AnimationPlayer")
animation_name = "die"
animated_sprite = NodePath("../AnimatedSprite2D")
animated_sprite_name = "die"
player_bounce = -200
[node name="CollisionShape2D" type="CollisionShape2D" parent="HitBox"]
position = Vector2(0, -11)

View File

@@ -6,6 +6,11 @@ extends Area2D
@export var animated_sprite: AnimatedSprite2D
@export var animated_sprite_name: String
func _on_body_entered(_body: Node2D) -> void:
@export var player_bounce: int
func _on_body_entered(player_body: Node2D) -> void:
var player_character_body = player_body as CharacterBody2D
player_character_body.velocity.y = player_bounce
animated_sprite.play(animated_sprite_name)
animation_player.play(animation_name)