Is there a fast way to animate dozens of sprites following a Path2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By avencherus
:warning: Old Version Published before Godot 3 was released.

I’m playing around with Path2D and it is something that I may want to use to animate things like chains. I’ve been wondering if there is some technique for quickly animating say 30-40 objects on a path, getting them to complete a full revolution, relative to their starting location on the path.

:bust_in_silhouette: Reply From: avencherus

I suppose nevermind. :slight_smile:

AnimationPlayer doesn’t seem to be suited for keyframing the unit offsets.

The solution that seems to work for me is this, hopefully there aren’t any floating point issues:

extends Path2D

export var step = .1

func _ready():
	set_process(true)
	
func _process(delta):
	
	for seg in get_children():
		var uo = seg.get_unit_offset()
	
		uo += step * delta
		# if(uo > 1): uo -= 1
		# edit: mod is a safer bet
			if(uo > 1 or uo < -1): uo = fmod(uo, 1)
	
		seg.set_unit_offset(uo)

I have made something like that too, with the option to add any ammount of nodepaths by demand, you can adapt that to the path length for a cleaner scene (I hate to see many nodepaths there >_>)

eons | 2016-11-04 00:26