Hello.
I’ve been experimenting with trains and I can’t seem to find a good solution for driving them so that they will follow the tracks. What kind of logic should I use for this kind of movement?
Help is appreciated.
Hello.
I’ve been experimenting with trains and I can’t seem to find a good solution for driving them so that they will follow the tracks. What kind of logic should I use for this kind of movement?
Help is appreciated.
Depends on what system you are using to move the trains in the first place.
Will they be cframed, using physics, body movers etc?
Whatever is the most efficient to accomplish this task.
If you want them to follow the tracks no program is required you just need a force moving them and gliders to make them follow the tracks
So if you attach some spheres onto the bottom of the train like this it will work fine:
I’ve thought about this but what happens if there is a junction?
It will still follow the rails as they are a spherical shape
Just make sure they are gradual turns not sudden like this exampleWhile this does work, it might not be reliable enough in some cases, and if the train is following a pre-set path it would be more efficient to use CFrame to follow the tracks. You probably want to look at this really helpful post by @EchoReaper
However that will lag more
It entirely depends on the implementation. More often than not using the method I suggested will lag less. (As I did say in my reply)
Programming a train to follow a predefined set of rails will not lag more than relying on constant collision solving to keep it on course, even if you are interpolating to make the ride appear smoother. Roblox physics of fast-moving trains may result in some disappointing behavior in a laggy server online.