Hello everyone. I'm working on a game idea where you control a sort of worm made up of multiple segments. The segments are supposed to interact according to some custom physics algorithms I've got. The details aren't that important but the main things I'll need to be able to determine are the position and velocity of the segments relative to each other and I also need collision checking with the environment and (eventually) other worms. I've been playing around with GDScript and got as far as this code:
func _ready():
screen_size = get_viewport_rect().size
var segments = Array()
var sprites = Array()
var colliders = Array()
for i in range(0,5):
var nodeScale = 0.2 + (5 - i) * 0.1
segments.append(Area2D.new())
sprites.append(Sprite.new())
colliders.append(CollisionObject2D.new())
segments[i].transform.origin = Vector2(10 * i, 15 * i)
segments[i].scale.x = nodeScale
segments[i].scale.y = nodeScale
sprites[i].texture = load("res://wormseg1.png")
sprites[i].transform.origin = Vector2(10 * i, 15 * i)
sprites[i].scale.x = nodeScale
sprites[i].scale.y = nodeScale
#echoSegment.set_script(wormSegmentScript)
self.add_child(segments[i])
self.add_child(sprites[i])
self.add_child(colliders[i])
print(i)
This produces 
The whole structure moves together (I added some keyboard control). So far so good I suppose. What I'm trying to understand is the relationships amongst parent node, subnodes, sprites, and colliders. The one large sprite is there even if I remove the loop. I noticed that applying a transform to a collider wasn't allowed. I am aware that there is support for extended 2D objects and collisions but the segments are supposed to move in a fairly specialized way (the segment positions are ultimately not just going to be a linear function of their index for instance) so I thought it would be best to understand how all this works at a low level. I'm new to GDScript but have a strong background in Python and C++. Basically, I'm just trying to learn how Godot 2d physics and nodes interrelate so I can work out how best to write the player logic. What is a good reference on that?