Welcome to the forums @AlphaVDP2!
What you may be able to do if you want to use multiple Path3D and PathFollow nodes, one each for the Path3D nodes. The PathFollow nodes should be completely separate from the train, but where you can get them when you need them, like having each Path3D keep a reference to it's PathFollow node. Then you can have your train know which Path3D it's on and use the PathFollow node when moving on the track. Then when it's reached the end of the track, you can get the next Path3D and PathFollow. That way, you can still use Path3D and PathFollow nodes.
Hopefully what I wrote above makes sense... :sweat_smile:
If it doesn't make sense, let me know and I'll try to explain it better.
For creating such a system, the code could look something like this:
# In the Path3D node
# =================
extends Path3D
var path_follow : PathFollow
# a reference to the next Path3D
# you will need to connect them in the editor if using an exported NodePath like below
export (NodePath) var next_path_nodepath = null
var next_path = null
func _ready():
path_follow = get_node("PathFollow")
if (next_path_nodepath != null):
next_path = get_node(next_path_nodepath)
# =================
# In the train
# ==========
var current_path = null
const MOVE_SPEED = 2.0
# You'll need go somehow, depending on your project, get the first path that you start on and assign it to current path.
func _process(delta):
# example - move the train by moving the path follow
if (current_path != null):
# go down the path:
current_path.path_follow.offset += delta * MOVE_SPEED
# move to the path follow position
global_transform.origin = current_path.path_follow.global_transform.origin
# are we at the end of the track?
if (current_path.path_follow.unit_offset >= 1):
# is there another path?
if (current_path.next_path != null):
# set that as the current path (assumes a path ends exactly where a new one starts
current_path = current_path.next_path
# set the path follow to the start
current_path.path_follow.unit_offset = 0
# move to the start position
global_transform.origin = current_path.path_follow.global_transform.origin
# if there is not another path, then just stop moving
else:
current_path = null
# ==========
I have not tested the code at all, so I have no idea if it would work, but if I was trying to use multiple Path3D nodes and PathFollow nodes for a train, I'd try to do something like the code above. :smile: