Files
godot-demo-projects/2d/finite_state_machine/player/bullet/bullet_spawner.gd
Yaxian 1d8fa9c44d Add player_state dictionary to manage player state names for FSM demo (#1143)
* Add player_state dictionary to manage player state names for FSM demo

* Use a constant typed Dictionary of StringNames and update to Godot 4.5

---------

Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
2025-10-01 21:33:27 -07:00

19 lines
403 B
GDScript

extends Node2D
var bullet := preload("Bullet.tscn")
func _unhandled_input(input_event: InputEvent) -> void:
if input_event.is_action_pressed("fire"):
fire()
func fire() -> void:
if not $CooldownTimer.is_stopped():
return
$CooldownTimer.start()
var new_bullet := bullet.instantiate()
new_bullet.position = global_position
new_bullet.direction = owner.look_direction
add_child(new_bullet)