How to use a path to control the motion of multiple objects

Godot Version

4.5.1

Question

How do you use a path 3d to control the motion of multiple objects?

I have a series of animated models, I want them to move along a similar path. Using a path 3d and a path follow node I can get the right effect for the first mesh, but the entirety seem to be treated as a cube, not maintaining their individual positions along it. If all the meshs behind it will be transformed to match its orientation on the pathyou have a look at my SC what I desire is for each object to stay along the path with its relative transformation.

Pretty sure I can get the effect I want by re-parenting each one to an individual path follow and then animating each path follow node. But I’m probably going to end up with ~100-ish of them. Is there a more convenient way to get this to work using just a single path and follow node?

You can make one single parent Node3D that has all birds (or whatever it is) as children and then animate this Node3D along the path. All the children will automatically follow.

1 Like

that made no difference, the result is the same

Can you post a short video of how it looks like currently?
Maybe I’m misunderstanding something.

so if u look at the screen shot, I want each bird to follow the line, not transform with the cube like shape along the green line

How can it follow the line if its not on the line?

I’m moved them all a little, their relative transform isnt much. If I do this with only one of them per line i get the effect I want. Similar to how follow paths work in blender. Here that yellow cube is used to transform all the children to follow the path, which is not what I want.

I didn’t mean that literally, I was trying to explain what I’m trying to achieve to the previous reply.

Each will need its own follow path node but they all can be parented to the same path node.

aw I was trying to avoid that

Why avoid?

I see what you mean. You can attach this script to your children, it will copy the parent’s (PathFollow3D) movement, just offset a little bit.

extends MeshInstance3D

@onready var initial_offset: Vector3 = position

func _process(delta: float) -> void:
	global_position = get_parent().global_position + initial_offset

It gives a smooth motion like that, instead of the original box-like:

like i said in the post, I need way more than the ones 'I’ve displayed here. to do it one by one while take a while since I’ll need to set up ~100 or so

I appreciate the effort, not sure its that simple since its along a curved path, so the front model isn’t just a simple (x,y,z) distance away. Doing it individually will allow me to edit them for a better render result too. Thanks anyway

It works with a curved path too.
How is this not what you want?

Well it’d certainly be crazy to set 100 of them manually. That’s why we have computers that can do loops. Write an editor script if you want to set them up in the editor or a runtime script that executes at startup.

You can also animate just one on the path and script the rest of them to follow in a flocking/boid fashion. Something like @wchc already suggested but with some more finesse added.

1 Like

Does it still work if they are in a line behind it going much further back?

You seem to have a very specific vision of how this should look like, so why don’t you try it out for yourself in your project and see if matches your expectations? Use the source code I provided and let me know then.

1 Like

I have tried it, the result is the same as without the script. Respectfully, this is what I expected from reading your code. I appreciate you trying to help me out but it seems I either need to spend some time modelling the path mathematically or just bite the bullet and take the long shortcut.

Long shortcut it is

I tried using boids, but my frame rate tanks, I’ve tried using node 3ds as the route note rather than a rigid body too but I don’t like the result. I’m afraid I will just have to do it manually.

Loops would be usefull if it was a simple copy and paste job, it isnt. I’m going to need to set up alot of paths for different routes too.

No, don’t do it manually. Script it.