From 9306f1e18dde05aab030a0c01405fd25296a58ed Mon Sep 17 00:00:00 2001 From: magnetotail Date: Sat, 12 Jun 2021 15:03:50 +0200 Subject: [PATCH] Moved guests to own node --- World.gd | 4 +++- World.tscn | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/World.gd b/World.gd index f4cfb4c..315d182 100644 --- a/World.gd +++ b/World.gd @@ -1,6 +1,7 @@ extends Node2D onready var streets = $Streets +onready var guests = $Guests var Guest = load("res://Guest.tscn") @@ -22,4 +23,5 @@ func _on_GuestTimer_timeout(): print('new guest at: %s' % [guest_position]) var guest = Guest.instance(); guest.position = guest_position; - add_child(guest) + guests.add_child(guest) + print('Guest count: %s' % [guests.get_child_count()]) diff --git a/World.tscn b/World.tscn index 2b1203c..bb6ba38 100644 --- a/World.tscn +++ b/World.tscn @@ -222,19 +222,21 @@ position = Vector2( 520.662, 230.739 ) [node name="DropOffPoint3" parent="." instance=ExtResource( 4 )] position = Vector2( 166.312, 322.885 ) -[node name="Guest" parent="." instance=ExtResource( 5 )] -position = Vector2( 337.119, 100.387 ) - -[node name="Guest2" parent="." instance=ExtResource( 5 )] -position = Vector2( 761.14, 102.634 ) - -[node name="Guest3" parent="." instance=ExtResource( 5 )] -position = Vector2( 758.143, 376.075 ) - [node name="GuestTimer" type="Timer" parent="."] wait_time = 5.0 autostart = true script = ExtResource( 8 ) -[connection signal="picked_up" from="Guest" to="." method="_on_Guest_picked_up"] +[node name="Guests" type="Node" parent="."] + +[node name="Guest" parent="Guests" instance=ExtResource( 5 )] +position = Vector2( 337.119, 100.387 ) + +[node name="Guest2" parent="Guests" instance=ExtResource( 5 )] +position = Vector2( 761.14, 102.634 ) + +[node name="Guest3" parent="Guests" instance=ExtResource( 5 )] +position = Vector2( 758.143, 376.075 ) + [connection signal="timeout" from="GuestTimer" to="." method="_on_GuestTimer_timeout"] +[connection signal="picked_up" from="Guests/Guest" to="." method="_on_Guest_picked_up"]