A CFrame-based train moving system

I am trying to script a train system for my game as I got a physics-based system but that is not always very good at doing smooth motion and it’ll get stuck sometimes, if the curve is any too sharp. Hence I am looking into making one that is based on CFrame, so it should work better than what I had before.

What do you want to achieve?

I want to make a a versatile and smooth train system, which does not include the using of tweening or similar.

What is the issue?

I am unable of figuring out the theory of getting the train to turn whenever it needs to, right now it can only go in a straight line.

What solutions have you tried so far?

I have tried tweening, but that isn’t quite what I am aiming for. On the CFrame side, I have also tried so it’ll orient the train whenever it touches a node block but that does not work

Any help is appreciated.

1 Like

Try looking at mathematical curves.

Two commonly used one is

  1. Bezier Curves
  2. Catmull-rom spline

I think catmull better as it passes through the points so you should start from there.

How would I know when to start the curving?

I made up a physics based train setup that worked pretty well for another “tutorial” post a while back. There is a sample train system in my post that worked really well because it would travel insanely fast with about 10 degree angles in the track sections and wouldn’t derail.
Check it out here: