blob: 09ffa3ce1ce43b9c08e528a56658545e5a661fad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
extends Node2D
@export var arrow : PackedScene
@export var speed : float
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func action() -> void:
var pivot = get_node("../../")
var new = arrow.instantiate()
new.init_vel = Vector2.DOWN.rotated(pivot.rotation) * speed
new.global_position = global_position
var normalised = new.init_vel.normalized()
new.sprite.rotation = atan2(normalised.y, normalised.x)
get_tree().get_root().get_node("Node2D").add_child(new)
|