Files
godot-demo-projects/2d/finite_state_machine/player/bullet/bullet_spawner.gd
A Thousand Ships 0343cedd48 General proofreading (#1262)
* General proofreading for grammar and spelling
* General formatting
* Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
2025-10-11 01:39:59 -07:00

19 lines
404 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)