Files
godot-demo-projects/2d/finite_state_machine/player/bullet/bullet_spawner.gd
2020-06-08 22:43:19 -04:00

18 lines
337 B
GDScript

extends Node2D
var bullet = preload("Bullet.tscn")
func _unhandled_input(event):
if event.is_action_pressed("fire"):
fire(owner.look_direction)
func fire(direction):
if not $CooldownTimer.is_stopped():
return
$CooldownTimer.start()
var new_bullet = bullet.instance()
new_bullet.direction = direction
add_child(new_bullet)