Deleting Points on a Textured Line2D makes the Texture Scroll

Godot Version

4.2.1

Question

I’m a beginner, so bear with me if the solution might be obvious to you.

Currently, I’m working on a simple top-down tank game. I’m utilizing two of Godot’s built-in Line2D Nodes to render tracks of the tank individually using a tiled/repeating texture.

Video example on YouTube

My problem occurs when I try to delete points of the tank tracks. Deleting points, as in this code snippet, causes the Line2D’s texture to scroll, which I don’t want:

	if tank.is_moving or tank.is_turning: 
		track_left.add_point(track_left_point_location.global_position)
	
	if track_left.points.size() > track_max_length:
		track_left.remove_point(0)

I attempted to fix the scrolling by only adding and deleting points when the tank traveled a fixed distance, like this:

	if track_left.points.size() == 0:
		track_left.add_point(track_left_point_location.global_position)
	if track_left.points.size() > 0:
		var last_point_pos = track_left.points[track_left.points.size()-1]
		if track_left_point_location.global_position.distance_to(last_point_pos) >= points_every_x_units:
			track_left.add_point(track_left_point_location.global_position)
			if track_left.points.size() > track_max_length:
				track_left.remove_point(0)

or by creating and deleting points with a timer on a signal, like this:

	if track_left.points.size() == 0:
		track_left.add_point(track_left_point_location.global_position)
		point_timer.start(placement_timer_time)
	if timeout: 
		track_left.add_point(track_left_point_location.global_position)
		if track_left.points.size() > track_max_length:
			track_left.remove_point(0)
		timeout = false

These two tests resolved the scrolling of the tracks when the tank travels on a straight line, but the moment I delete points on a curve, the scrolling reappears.

You can find a minimal reproduction project (v4.2.1 stable) for this issue here: Minimal Reproduction Project Download

I would be glad if any of you could help me out with this; I have been banging my head on this for some time. Thanks in advance!

You might consider using MultiMeshInstance2d to simulate a scrolling trail.

Thanks for your suggestion! However, my issue is slightly different.

I’m trying to prevent a Line2D’s texture from scrolling when deleting a point.
Any insights on how to address this would be appreciated.

I’ll look into MultimeshInstance2D in the meantime.

My suggestion is to use a texture instead of a line and use multimeshinstance to draw the trajectory. It’s highly flexible and has good performance.