25 lines
438 B
GDScript3
25 lines
438 B
GDScript3
|
|
class_name Grenade extends RigidBody2D
|
||
|
|
|
||
|
|
var timer = Timer.new()
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
add_child(timer)
|
||
|
|
#how long
|
||
|
|
timer.wait_time = 2
|
||
|
|
#one time onlu
|
||
|
|
timer.one_shot = true
|
||
|
|
timer.connect("timeout",explode)
|
||
|
|
timer.start()
|
||
|
|
|
||
|
|
func explode()->void:
|
||
|
|
print('ima spolde')
|
||
|
|
self.queue_free()
|
||
|
|
|
||
|
|
|
||
|
|
func _on_body_entered(body: Node) -> void:
|
||
|
|
print("collision w Grenade!!")
|
||
|
|
|
||
|
|
if body.is_in_group("destructible"):
|
||
|
|
body.queue_free()
|
||
|
|
explode()
|