19 lines
435 B
GDScript
19 lines
435 B
GDScript
extends CharacterBody2D
|
|
|
|
@export var damage = 12.0
|
|
@export var knockback = 4
|
|
|
|
func _physics_process(delta):
|
|
var collision = move_and_collide(velocity * delta)
|
|
|
|
if collision:
|
|
var collider = collision.get_collider()
|
|
if collider is Enemy:
|
|
var normal = collision.get_normal()
|
|
collider.velocity = collider.velocity.bounce(normal) * knockback
|
|
collider.take_damage(damage)
|
|
queue_free()
|
|
|
|
func _on_timed_out():
|
|
queue_free()
|