27 lines
593 B
GDScript
27 lines
593 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() -> void:
|
|
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: float) -> void:
|
|
pass
|
|
|
|
func explode()->void:
|
|
print("ima splode")
|
|
self.queue_free()
|
|
|
|
|
|
func _on_body_entered(body: Node) -> void:
|
|
print("Grenade hit something")
|
|
if body.is_in_group("explodable"):
|
|
body.queue_free()
|
|
explode()
|