Help with a Automatic CFrame train with Multiple cars

Hi yal! Im currently making a automatic peoplemover (train) system with multiple cars that utilizes tween w/ cframe to move.

My current system is a very tradional Cframe + Tween System, With multiple nodes on the track that the train moves (tweens between) to to reach its destiantion station.

For better server-side performance, The Tween is done entirely on the client, Sent via RemoteEvents.

The main issue i have encountered is having the multiple carriages of the train move together with a constant distance between them, Currently the distance between cars is very choppy and laggy.

Before i encountered this issue, I have nodes of the track spaced between equally by the distance between 2 cars. So if car1 is at node 4, car2 would be one node behind (node3) and so on Then the script will tween all cars at once instead of independently. This made the distance between 2 cars equal throughout the entire route and looked good. The main issue i encountered with this method is that it does not allow for nodes that aren’t equally spaced apart, which is very difficult especially to do when trying to make a single track branch out into 2 tracks then stop at the station at the same space on one axis.

So to solve this, I instead made every car perform their tweens individually (On different threads), This Utilizing Coroutines. This adds the ability for the train to move between several nodes that arent equally spaced apart, But this has introduced the current issue I’m facing, Unequal spacing between cars making the system look janky and laggy.

So im currently looking for any alternative movement systems that utilize the same cframe based system (not wanting to make a alignposition / rotation system since it utilizes physics, thus increasing possibility of server lag.)

I Have also looked at various DevForum Articles, Videos and The Developer Hub, Many of which helped me to get to this stage but my scripting knowleage isnt very great and i havent been able to understand some of them as much as i should.

Any help, advice or small comments are very much apprecitated!

(This is also my first time writing a Scripting support post, So it might be a bit hard to read. I apologize in advance!)

^^ Here is a video of my system. As I have mentioned, The distance between the cars changes during the route and is very janky looking.

4 Likes

Hi hopefully this could be helpful.

you mentioned for better server side performance you are tween on the client. I wouldn’t recommend this, if you want multiple players on the same train. given that the any individual player doesn’t simulate the physics for another player this could lead to random teleporting of players. If you had the train movement/tweening done on the server then the roblox engine would deal with that networking issue.

Now for your main question another way to move the train. I would recommend Bezier Curve’s as they provide far smoother movement even though they have some challenges with getting a linear movement. One way you could position the trains behind the first train is, first positioning the individual carriage’s connector over the connector of the carriage infront and then next rotating the carriage around that connector until its center is along the Bezier Curve. This would keep this distance between carriages the same.

2 Likes

Im so sorry for being such a noob, But how would a bezier curve system be implemented? I’d like to know more.
Is it by caculating the curve first then placing nodes on it or something else? I’ve been told a few times to use bezier curves for my train system but never quite got what it meant.

You need 4 points to calculate a Cubic Bézier Curves, these you would most likely need to place by hand. 2 of these points would be the track and the other two would define the curve.

Thanks for steering me in the right direction! with further research, I think i know where to start now.
I’l be updating the post when i have it done!!
(also decided to use CatRom’s instead of bezier curves because of the added benefits.)

1 Like

Hi guys! Its been a while, But recently I polished up my CatRom Automated Train system and it works nicely! Check it out here → 新交通システムテスト / Automated Guideway Transit Testing - Roblox
If anyone wants any info on how it works, I can provide a detailed explanation!
Unfortunately I wont be uncopylocking it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.