23 lines
670 B
GDScript
23 lines
670 B
GDScript
extends Node
|
|
|
|
# Exports
|
|
@export var player: PlayerCharacter
|
|
@export var arrow_parent: Node2D
|
|
|
|
# Preloads
|
|
const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx")
|
|
|
|
# Private Methods
|
|
func _ready() -> void:
|
|
var firing_arrow_state: FiringArrowState = player.get_node("State Machine/States/Firing Arrow State")
|
|
firing_arrow_state.ArrowFired.connect(_on_arrow_fired)
|
|
|
|
|
|
func _on_arrow_fired(fire_position: Vector2, direction: Vector2) -> void:
|
|
var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile
|
|
wooden_arrow.SetProjectileStartAndDirection(fire_position, direction)
|
|
|
|
if arrow_parent == null:
|
|
return
|
|
arrow_parent.add_child(wooden_arrow)
|