From ff2137367f7f7f3e5fd183186389182796d35ee7 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sat, 30 Sep 2023 20:16:14 +0200 Subject: [PATCH] made basic spawner --- spawner/spawner.gd | 10 ++++++++++ spawner/spawner.tscn | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 spawner/spawner.gd create mode 100644 spawner/spawner.tscn diff --git a/spawner/spawner.gd b/spawner/spawner.gd new file mode 100644 index 0000000..d6981c7 --- /dev/null +++ b/spawner/spawner.gd @@ -0,0 +1,10 @@ +extends Node2D +class_name Spawner +@export var scene: PackedScene +@export var target_parent: NodePath + +func spawn(): + var scene_instant= scene.instantiate() + scene_instant.position=Vector2.ZERO + add_child(scene_instant) + print(scene_instant.global_position) diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn new file mode 100644 index 0000000..91a3670 --- /dev/null +++ b/spawner/spawner.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://c67lfbk4gf1ga"] + +[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] + +[node name="Spawner" type="Node2D"] +script = ExtResource("1_xqfmg") + +[node name="Timer" type="Timer" parent="."] +wait_time = 2.908 +autostart = true + +[connection signal="timeout" from="Timer" to="." method="spawn"]