1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-29 10:54:18 +00:00
swear-jar/interface/ghost/instantiator.gd

28 lines
677 B
GDScript3
Raw Normal View History

2023-10-08 01:56:29 +00:00
extends Node
class_name Instantiator
## The [PackedScene] that this node should instantiate.
@export var scene_to_instantiate: PackedScene
## The [Node] instantiated scenes should be attached to.
@export var container: Node
## The [Node2D] instantiated scenes should get properties from.
@onready var target: Node2D = get_parent()
func instantiate():
var inst = scene_to_instantiate.instantiate()
inst.global_position = target.global_position
inst.rotation = target.rotation
container.add_child(inst)
instantiated.emit(inst)
# TODO: Remove this
return inst
## Emitted when the [instantiate] function has finished executing.
signal instantiated(new_scene: Node)