I'm having a bit of trouble with getting a sprite to follow (or appear on) a PathFollow2D when I create the PathFollow2D via script.
path2d = Path2D.new()
curve = path2d.curve
#Add curve points to create a planetary orbit
curve.add_point ( Vector2 (0, yrad), Vector2( 0, 0 ), Vector2( xrad, 0 ), -1 )
curve.add_point ( Vector2 (xrad, 0), Vector2( 0, 0 ), Vector2( 0, -yrad ), -1 )
curve.add_point ( Vector2 (0, -yrad), Vector2( 0, 0 ), Vector2( -xrad, -0 ), -1 )
curve.add_point ( Vector2 (-xrad, 0), Vector2( 0, 0 ), Vector2( 0, yrad ), -1 )
curve.add_point ( Vector2 (0, yrad), Vector2( 0, 0 ), Vector2( 0, 0 ), -1 )
#Add a new PathFollow2D as a child of the Path2D
var followpath = path2d.get_child(0)
#Create a test sprite and set its texture
var testsprite = Sprite.new()
#Add testsprite to the FollowPath2D
#Draw orbit of planet
draw_polyline(curve.get_baked_points(), Color(1,1,1,.1), 2.0)
followpath.set_offset(followpath.get_offset() + 50 * delta)
The above is a simplified version of what I'm trying to do (my actual script generates multiple orbits, then pulls from sprite factories etc) but even the above isn't working for me.
If I print the name of "testsprite" it gives me Sprite 12312 or whatever random number it generated, as opposed to "Null," but there is no sprite visible in-game (as far as I can see). I see the drawn Path2D, but not the child "testsprite."
I also deleted the background in the scene to ensure the sprite isn't simply appearing beneath the background.
If I haven't given enough info, let me know and I can add more. Thank you in advance!