Files
godot-demo-projects/2d/finite_state_machine/player/bullet/bullet_spawner.gd
2020-02-02 20:28:25 -05:00

18 lines
327 B
GDScript

extends Node2D
var bullet = preload("Bullet.tscn")
func _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)