mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-07 00:10:09 +01:00
* 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>
19 lines
403 B
GDScript
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)
|