beta-1.0
This commit is contained in:
24
Scripts/Entity Spawners/arrow_spawner.gd
Normal file
24
Scripts/Entity Spawners/arrow_spawner.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Node
|
||||
|
||||
@export var arrow_parent: Node2D
|
||||
|
||||
const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx")
|
||||
|
||||
# Public Methods
|
||||
func OnArrowFired(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)
|
||||
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
var players := get_tree().get_nodes_in_group("Player Group")
|
||||
if players == null or players.is_empty() or players[0] is not PlayerCharacter:
|
||||
return
|
||||
|
||||
var player := players[0] as PlayerCharacter
|
||||
player.ArrowFired.connect(OnArrowFired)
|
||||
Reference in New Issue
Block a user