ed-april-game/scripts/grenade.gd
2026-05-04 20:57:02 -04:00

25 lines
456 B
GDScript

class_name Grenade extends RigidBody2D
var timer = Timer.new()
func _ready() -> void:
add_child(timer)
timer.wait_time = 2
timer.one_shot = true
timer.connect("timeout", explode)
timer.start()
func explode() -> void:
print("explode")
self.queue_free()
func _process(delta: float) -> void:
pass
func _on_body_entered(body: Node) -> void:
print("collision with grenade")
if body.is_in_group("destructable"):
body.queue_free()
explode()