I want to make a path follower scene that would let me draw a path to automatically spawn a certain scene along it, and then stop. My current code for the PathFollower2D node is as follows:
extends PathFollow2D
@export var step: float = 32.0
var ring_scene = preload('res://code/entities/inanimate/Ring.tscn')
# Called when the node enters the scene tree for the first time.
func _ready():
print('trying to follow !')
var highest: float = 0.0
while progress_ratio < 1.0:
if progress >= highest:
highest = progress
var ring_instance: StaticBody2D = ring_scene.instantiate()
add_child(ring_instance)
print(get_children())
ring_instance.position = global_position
progress += step
elif progress < highest:
break
for i in get_children():
print(i, ' ', i.position)
print('done !')
func _process(delta):
# extra debug discard later
if Input.is_action_just_pressed("down"):
print(get_children())
for i in get_children():
print(i, ' ', i.position)
This seems to technically work, since the print statements up confirm the scenes have been instantiated, added to this node, and are even in the right positions. But in-game, they don't show up at all, and they can't be interacted with in any way, as if they aren't present. I'm pretty much stumped at this point, any help is appreciated.