Files
godot-demo-projects/2d/finite_state_machine/player/bullet/bullet_spawner.gd
Hugo Locurcio 7befd7c718 Enable physics interpolation in all 2D demos (#1070)
This makes uses of the new built-in 2D physics interpolation
added in 4.3.

For 3D demos, a separate PR requiring `master` will be made later.
2025-04-14 18:58:38 +02:00

19 lines
391 B
GDScript

extends Node2D
var bullet := preload("Bullet.tscn")
func _unhandled_input(event: InputEvent) -> void:
if 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)