23 lines
588 B
GDScript
23 lines
588 B
GDScript
extends Node2D
|
|
|
|
@export var bullet_scene: PackedScene
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("shoot"):
|
|
$Timer.start()
|
|
_on_timer_timeout()
|
|
elif event.is_action_released("shoot"):
|
|
$Timer.stop()
|
|
|
|
|
|
func _on_timer_timeout() -> void:
|
|
$AudioStreamPlayer.play()
|
|
print("yeth")
|
|
var bullet = bullet_scene.instantiate()
|
|
get_owner().get_owner().add_child(bullet)
|
|
bullet.global_position = $Marker2D.global_position
|
|
|
|
var bullet2 = bullet_scene.instantiate()
|
|
get_owner().get_owner().add_child(bullet2)
|
|
bullet2.global_position = $Marker2D2.global_position
|