I'm trying to make a train mesh follow a curve path. The Curve modifier does this admirably, unfortunately I need to export the animation to a game engine so a modifier just won't do.
I tried adding bones to the mesh but it turns out making those follow a curve is not trivial. I copied the workflow outlined here by adding a second "helper" curve, making that one follow the path with the Curve modifier and putting a Spline IK constraint on the tail bone targeting the helper curve.
This works perfectly as long as my path is flat. Unfortunately, even the tiniest hill causes my train to flip over and do a full 360 (in direction of travel) around the track in one specific location, and I can't figure out why.
I tried all sorts of settings on both curves. Handles are aligned, twisting is set to Z-Up on both curves, and I added multiple Limit Rotation constraints to the bones. Nothing helps. It's interesting to note that when I set the helper curve to extrude, I can see that it stays perfectly upright when following the path:
So it's only the bones rotating, presumably because of the Spline IK constraint.
Please help, I'm going bald pulling my hair out over this. Any solution that keeps the wagons upright in this setup is welcome, though I'm also open to alternate suggestions on how to get them to follow the curve in the first place. I've uploaded the .blend file so you can take a better look at what I'm doing: