AprilGameExample/Scripts/grenade.gd

25 lines
440 B
GDScript

class_name Grenade extends RigidBody2D
var timer = Timer.new()
func _ready() -> void:
add_child(timer)
#how long
timer.wait_time = 2
#one time only
timer.one_shot = true
timer.connect("timeout", explode)
timer.start()
func explode()->void:
print("ima splode")
self.queue_free()
func _on_body_entered(body: Node) -> void:
print("Collision w Grenade!!")
if body.is_in_group("destructible"):
body.queue_free()
explode()