All Questions


yousef bohadi

Tail not following Sonics (Head)

When I test the scene, as done by the end of the video, I see the tail diverting from the path of the head (1). Upon checking the settings in the UI it turned out that the y value for the line was altered and not the x. And checking on the rotation it turned out that it was 90 degrees by default (2). I tried the following in code:

func set_length(value: float):
	length = value
	tail.points[-1].y = -length
	head.position.x = -tail.points[-1].y + tail.position.y

It still seems weird in the end as the tail extends into the head after returning to the original position (3). How can I set the default rotation of the tail to be 0 degrees and still align correctly with the head, I doula like to do that in order to use the exact code written in the video.


  • Here is an idea using a Position2D node to solve this relatively easily:

    • Add a Position2D node as a child of the head, where you want the tail to anchor
    • In set_length, set the tail's last point to that Position2D node's position.

    The Tail and Head nodes should stay as siblings in the scene tree for this to work. This will allow you to change where the tail anchors in the editor.

    Also, you will need to ensure that the Tail node's position is Vector2(0, 0) and that it's the points themselves that are at an offset from the origin for this to work.