Rollercoaster Problem: Bones following Curve 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:
I managed to find a solution, but it's a bit of a hack. Most notably, the process involves baking the animation, so it needs to be redone every time you want to change the layout of the curve.


select every bone in the chain and make sure "Inherit Rotation" is turned OFF
keyframe your "helper" IK curve to whatever you want the train to do (I wanted mine to go full circle around the curve)
Add a cube or empty somewhere high up in the scene (doesn't matter what it is)
make a copy of the armature/mesh in case we want to go back
bake action (visual keying and clear constraints)
select every bone and add a locked track constraint to each one, targeting the cube or empty or whatever you added in step 3. Fiddle with the settings until it makes your train stay upright.
bake again and export for use in Unity or other game engine.


Simple, right? Repeat steps 5-7 every time you change the curve or otherwise modify the setup. I'd much prefer adding the locked track constraints without baking in step 5 to avoid this, but I simply cannot get that to work, the Spline IK constraint overrides my Y axis rotation. So this will have to do. If anyone has a better way to do this I'd be very much interested.