File tree Expand file tree Collapse file tree
game/ship_skeleton/cell_modifications Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11class_name BasePlayerTurret
22extends Node2D
33
4+ @export var _attack_cooldown := 1.0
5+
6+ var _can_shoot := true
7+
48@onready var shooting_pos : Marker2D = % ShootingPos
9+ @onready var attack_cooldown_timer : Timer = % AttackCooldownTimer
10+
511
12+ func _ready () -> void :
13+ attack_cooldown_timer .timeout .connect (func ():
14+ _can_shoot = true
15+ )
616
7- func _unhandled_input (event : InputEvent ) -> void :
8- if event .is_action_pressed (& "shoot" ):
17+ func _physics_process (delta : float ) -> void :
18+ if Input .is_action_pressed (& "shoot" ) and _can_shoot :
19+ _can_shoot = false
20+ attack_cooldown_timer .start (_attack_cooldown )
921 # NOTE. For player will shot straight for now. For AI perhaps could rotate turrets.
1022 # var direction := shooting_pos.global_position.direction_to(get_global_mouse_position())
1123 var direction := Vector2 .RIGHT .rotated (global_rotation )
Original file line number Diff line number Diff line change @@ -19,3 +19,7 @@ texture = ExtResource("3_jnh57")
1919[node name ="ShootingPos" type ="Marker2D" parent ="." unique_id =1957190253 ]
2020unique_name_in_owner = true
2121position = Vector2 (35 , 0 )
22+
23+ [node name ="AttackCooldownTimer" type ="Timer" parent ="." unique_id =1691874727 ]
24+ unique_name_in_owner = true
25+ one_shot = true
You can’t perform that action at this time.
0 commit comments