mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 16:00:08 +01:00
18 lines
337 B
GDScript
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)
|