This repository has been archived on 2024-09-30. You can view files and clone it, but cannot push or open issues/pull-requests.
gbjam12/puzzles/arrow/arrow_shooter.gd

20 lines
473 B
GDScript

extends RayCast2D
@onready var arrow: PackedScene = preload("res://puzzles/arrow/arrow.tscn")
@onready var timer: Timer = $ShootTimer
@onready var shoot_dir: Vector2i = self.target_position.normalized()
@export var arrow_speed: int = 400
@export var shoot_timer: float = 3.0
func _ready():
timer.start(shoot_timer)
func _process(delta):
pass
func _on_shoot_timer_timeout():
var inst: Arrow = arrow.instantiate()
inst.shoot(shoot_dir, arrow_speed)
add_child(inst)