Recently I’ve been working on several games that contain a lot of train lines, and I’ve scripted a lot of train systems that work in different ways from TweenService to BodyVelocity (look in Train Images).
Train Images
Trains build by Macovei2057 VVV
Trains build by me VVV
However, every one of these has its own disadvantages, especially when it comes to curved rails/Tracks.
For example:
TweenService is not smooth when it comes to curved tracks, in other words, it looks odd when it moves from 1 checkpoint to another. + it setting it up is hard and takes a lot of time (look in Train Tween).
Body Velocity is a lot smoother when it comes to curves, however, there is always a chance that it might get the train stuck in the middle of the way, in other words, it’s not stable since it uses Roblox physics which is not the greatest to work with.
Hmm, for working with curved tracks why not just directly manipulate the train through CFrames and RenderStep?
You find the change in position path along the curve using Bezier curves over time and hence the movement of the train in a curvy manner which should fit your criteria for curved rails/Tracks. https://developer.roblox.com/en-us/articles/Bezier-curves
For the orientation, that would be a bit more difficult but possible if you work with raycasting to obtain the floor’s normal, and using the tangent of the bezier curve path (by obtaining points on the curve close to each other).
Moreover, CFrames have been known to be reliable as they directly change the position property of the train like TweenService with the downside being the physics of the train. For that you will need to rely on doing physics detection for the CFrame’d object like a wall stick controller if you want players to ride the train as passengers.
I was thinking of making the train only move to the direction it faces, with tween service. So whenever the orientation changes, right or left, the train will change its movement direction to the point that its facing.
Do you think that something like that is possible?