SeptemberGame/scripts/grenade.gd

28 lines
556 B
GDScript

class_name Grenade extends RigidBody2D
var timer = Timer.new()
# Called when the node enters the scene tree for the first time.
func _ready():
add_child(timer)
timer.wait_time = 2
timer.one_shot = true
timer.connect("timeout", explode)
timer.start()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func explode()->void:
print("ima splode")
self.queue_free()
func _on_body_entered(body):
print("grenade hit something")
if body.is_in_group("splodable"):
body.queue_free()
explode()