20 lines
473 B
GDScript
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)
|