Train Stuff with Paths

It’s probably been done before, but I didn’t see much in regards to animating it.

I’m quite new to Blender, yet did enough research to figure this much out. Basically I set up a train constrained to follow the same path as that used to guide replicated rails. That’s not quite right… Actually it’s the bogies or wheel trucks that are constrained to do the path following, and the cars are rigged onto them. (Otherwise it gets weird in tight turns.) The result looks realistic enough.

In this test video, the wheels are solid with no texture. So I didn’t need to animate them.

That’s ok, but I think it would be neat to have wheels that obviously roll along the track… (Which would also be useful for animating drive wheels and all the associated linkages on a steam engine.) So I did another attempt using what seems to be a common method to animate wheels. I decided to keep things simple while testing this aspect, so only did the wheel truck by itself.

The method that often is used to animate wheels is having a location to rotation transform, but as you can see (at the end) it fails when going around a turn. So it’s not much good if the wheels lock up when the railroad has a curvy path. (Originally I thought it was a bug, until somebody at the Blender IRC channel explained how such transforms work in better detail. Pretty much a linear vector kind of thing.)

So I came up with a tad convoluted driver based method to deal with that problem. (Excuse my noobishness, as I’m sure there’s a bit. And my math might not be perfect either - likely omitted some stuff needed for scaling wheels to different sizes.)

It works well, but it’s still not entirely ideal.

The process of figuring out how long a path is can be a bit tedious, but it’s necessary for good animation of wheels that roll without slipping. When asking around to see if there’s a better way, somebody pointed me to a very useful add-on that performs a fairly basic function that somehow was omitted from the curve properties. I believe it’s called “Object get path length”. So when I get around to doing some more tests in this regard, I’ll be using that. (Calculating path length manually is a bit awkward and slow, and the plugin is faster with more accuracy.)

Eventually my goal for these tests is to have a semi-realistic old fashioned steam engine travel around some meandering and occasionally crazy railroads.

Nice test and explanation of how to solve the rolling along a curve task!

I agree, that it would be nice if the path length was just exposed as a property of the curve itself.

Very cool. I’m intrigued how you did this bit:

Actually it’s the bogies or wheel trucks that are constrained to do the path following, and the cars are rigged onto them

in 2.49 there was a path length for curves. something that got lost in the update

It’d definitely be nice if somebody would add that particular aspect back. Knowing the length (or perimeter if closed) of a curve really is one of it’s fundamental properties. Obviously one doesn’t need to edit that directly, but having it auto-update with the associated curve and making it accessable for copying a data path would be very useful. But for now a plugin that manually needs to be updated and memorized will do.

I did make another video explaining how the rig is done. Like I said I’m a bit of a noob though, so my video is probably longer than it needs to be. It’s about 40 minutes. (Much of it fixing a mistake or two.) Yet if I can do it as a blender newbie, it should be easy enough for anyone else to do. I’ll post it here for your benefit or critique. (And feel free to show if you get good results or come up with some improved methods.)

Ooh - thanks for the tutorial. Not often you ask a question and get a 40 min tutorial as an answer :slight_smile: Interesting - the answer was much simpler than I was expecting, I guess I was over thinking it. Useful tips on making sure the location is zero - that often causes me problems.

A time saving tip in return - I saw you struggling through the menus to “snap to” quite a bit - the quick way is shift+s and it pops up at the cursor.

Thanks!