A CFrame driving system for a train

So, I am developing my train game, but I am having difficulties with the driving system. I am using BodyVelocity now, but I want a more reliable one. CFrame could be used, but I do not understand the logic behind a CFrame driving system. If someone would be able, I’d appreciate an explanation behind all it.

1 Like

A cframe velocity would look like this

local train = --define train local driver = --define train.Velocity = driver.Head.CFrame.LookVector*<studs per second>

Also, I would appreciate help here: How To Save a Folder to DataStoreService - #10 by XxMr_AltxX

I assume that by using BodyVelocity you were relying on Roblox’s physics engine to keep the train within bounds, you can’t do this using CFrame-based movement systems. (Not reliably at least)

You’ll have to come up with a guidance system for the train to follow, usually expressed in nodes that the train smoothly moves between to follow the desired path. This is similar to how people make rollercoasters in Roblox. This is not beginner-friendly though and requires a pretty in-depth knowledge of vector and matrix maths along with interpolation and curves.

Here’s some more info:

Yeah, CFrame based movement is not really reliable unless you are launching a projectile in one direction only.

I guess I’ll have to stick to bodyvelocity then