Hello there!
I'm trying to make some kind of train simulator on Godot, and I'm wondering how to implement the most important thing. The movement on rails.
I didn't want to use just a spline and PathFollow node at first - this simple solution is suitable for decorations only.
I tried using real train physics but quickly abandoned this because of too much inpredictability and unstability. Then I began to invent "crutches" like using a VehicleBody and VehicleWheels with auxilary collisions on the inner side of the rail, adopting the RaycastVehicle by Tobalotion, etc. After several defeats with physics I decided to return to splines. Will need to modify the original Path and PathFollow nodes, I think, but I have not enough coding skills to do it.
Now I'll try to explain.
How is the train sets in motion? Traction motors rotate the wheels that are fixed to the trolley. The body of the locomotive rests on trolleys via the pivot, so the trolley pulls the body, roughly speaking. The locomotive and the cars are connected by the couplers, so the locomotive pulls the body of the car that rests on its own trolleys and pulls them along.
I want to implement the same system, but PathFollow will be applied as an axis on which the trolley is mounted. The node will be just a helper to hold the trolley and rotate it in the right direction. The rest will be done with bones, joints and physics. The node itself should move along the spline freely or under the influence of any external forces. I think I need to calculate this forces and change the Offset parameter via code. I'll be gratefull if you give me an example of that code, if possible.
Also there is another question about the dynamically changing Path. I imagine that the railroad consists of some amount of splines (Curve3D). Each curve represents a railway section. This can be used for implementation of a signalling system and turnouts. So our Path should load the curves one by one as it moves. And it should know whether there will be a diverging on the next turnout (which represents two or more converging curves). Is that even feasible? If so, then I ask for help with code.
Thanks in advance.