From fc8d4bc8ac5836136bad02f027af7ba51acb9134 Mon Sep 17 00:00:00 2001 From: Cookie-CHR Date: Sun, 3 Apr 2022 16:44:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20Shooting=20time=20limitati?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/behaviours/BulletSpawn.gd | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/entities/behaviours/BulletSpawn.gd b/src/entities/behaviours/BulletSpawn.gd index c41e4ad..fb5afdb 100644 --- a/src/entities/behaviours/BulletSpawn.gd +++ b/src/entities/behaviours/BulletSpawn.gd @@ -5,11 +5,24 @@ export var bullet: PackedScene = preload("res://src/entities/Bullet.tscn") export var bullet_container_node_path: String = "../.." onready var bullet_container_node: Node = get_node(bullet_container_node_path) onready var source: Node2D = get_parent() +var _timer : Timer = null +func _ready(): + _timer = Timer.new() + add_child(_timer) + _timer.set_wait_time(0.3) + _timer.set_one_shot(true) + _timer.start() func _process(_delta): - if Input.is_action_just_pressed("player_shoot"): + print(_timer.get_time_left()) + if Input.is_action_just_pressed("player_shoot") and _timer.get_time_left()==0: shoot() + + #restart timer + _timer.set_wait_time(0.3) + _timer.set_one_shot(true) + _timer.start() func shoot():