1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 17:44:24 +00:00
hella-farm/behaviours/spawner.gd

20 lines
470 B
GDScript3
Raw Normal View History

2024-04-14 17:48:13 +00:00
extends Node2D
class_name Spawner
signal spawned(entity: Node2D)
@export var scene: PackedScene
@export var parent: Node2D
func spawn():
var entity = scene.instantiate()
entity.global_scale = global_scale
entity.global_position = global_position
entity.global_rotation = global_rotation
2024-04-15 19:51:24 +00:00
parent.add_child.call_deferred(entity) # Not sure why this is needed.
2024-04-14 17:48:13 +00:00
func _ready():
if parent == null:
parent = MainGame.get_ancestor(self).get_node("SpawnedEntities")
2024-04-14 20:36:14 +00:00