ed-april-game/scripts/grenade.gd

25 lines
456 B
GDScript3
Raw Permalink Normal View History

2026-05-05 00:57:02 +00:00
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()