Hi, I’m working on a train system and currerntly the train system I’ve got now is physics based and it works great but its not that smooth or is bouncy at times so I’ve been trying to move to a CFrame train. This CFrame train is a bit differen’t from most CFrame trains you’d see, this one isn’t node based, this one has more of a “curve sensor”, essenitaly what I mean is just like a physics train, it still has bogies that turn and collide with the rails heres my plan:
- Anchor the train
- Leave bogies unanchored as they use HingeConstraints and still need to rotate
- Use a Heartbeat or RenderStepped event to make the train move forward and this event will also make the train rotate based on the bogies orientation
So far heres the progress:
CFrame Train.rbxl (76.2 KB)
When testing, you’ll need to enable the script thats inside ServerScriptService.
It has a couple issues though, and the main issue I want solved is when the train goes fast the main engine will end up making the bogies derail from the track and then the whole system fails. How could I fix this? Do I need to move from a heartbeat event to a stepped event since it fires prior to a physics simulation? I think the issue is maybe the engine passes before the bogies turn, therefore derailing it.
If my idea using physical bogies to detect when the train turns isn’t very good idea and you have a better idea let me know!
I do not want to use a node based CFrame system for the following reasons:
Its harder to know when the train needs to switch track -Future feature
I need to add nodes everytime I build the track.
I don’t want to use loops to loop through differen’t sections of the train to find a curve either and this won’t be possible in the future for me because I plan to make the rails one whole mesh in blender instead of having mulitple meshes to make up a curve.
Any help appreciated! Thanks.