# Train composition animation

Hi,

I have a theoretical question.

What would be the best approach when considering animating a train composition (lokomotive+wagons connected with spherical joint) that moves along a curve.

1. Should we place the lokomotive as parent of all the wagons, and create spherical hinge connection. But then how do we say to the wagons to also move along the curve.

2. Should we use inverse kinematics. But then the last wagon should be the grand-grand parent, and lokomotive should follow the point along the curve. How would you then make all the wagons rotate/translate along with the curve, staying connected simultaneously to the curve and via the spherical joints?

3. Simply move each component along the curve, faking the spherical joints?

The use of IK is imperative in case of a train. On Bongoâs website is a page concerning IK (http://bongo.rhino3d.com/page/inverse-kinematics).
It holds a link to a sample model named âSimple Roller Coasterâ which might get you on the right track. (http://download.mcneel.com/s3/mcneel/bongo/2.0/samples/en/BongoIK_03.3dm)

I would also recommend you (being a novice) to take a look at my tutorial video âWhyâs of IKâ (http://bongo.rhino3d.com/video/whys-of-ik).

1 Like

Last I needed to place a complex train to a bend rail way for still rendering. The train based on 7 wagons (blocks). I use the flow along curve and history to get the straight train to the bend railway. The flow option was copy=yes rigid=yes local=no preservestructure=yes.
There was a problem with the connection between the wagons, but this wasnât visible. Finally I was able to move the straight source curve to fine adjust the position of the bend train. I use the trick often in the past, since moving/animating the simple straight source curve is easier than moving the whole train.

Thanks for sharing your experience Micha, unfortunately I do need the train-like animation not just still images. As I get more and more into IK I beginning to think itâs not possible unless you fake the connection between wagons and animate them separately.

Hi Luc,

Thanks for the provided info, I checked the sample models. The rollercoaster in particular.

There should be a fix on that, you canât call a roller coaster when it only moves in the XY plane.

If you move any of the control points of the rail-line vertically. You will notice that the IK fails. I donât know if this is due to IK limitation, Pre-calculation limiation or wrong methodology, but in theory as I understand it IK shouldâve made the calculation so that the wagons continue to follow the track upon itâs change.

Itâs a matter of mechanics. In order to follow a 3 dimensional track the hinges should be able to evolve 3 dimensional. If not the train is vertically stiff as a stick.

In BongoIK_03 001.3dm (78.9 KB) I made all hinges âUniversalâ allowing rotation along Y and Z axes â and the IK-solver finds a nice solution. 2 rotational axis suffice to give the joints enough freedom. Notice there is no telling how IK will make the chariots turn around their x-axis. When you add freedom of rotation around the X-axis youâll see the chariots even twist more. But then again âmechanicsâ âŚ in order to control the vertical position of the chariots a second rail is required.

I tested it here and this is the result. I wrote that I used it for a still image, but itâs easy to use for animation too. Maybe if not useful for your case itâs helpful later for an other user.

OK, the link parts between the wagons are a little misaligned, but I think this can be solved per special trick for this part. Itâs a question of the needed link part. Maybe the little misalignment is no problem. I like the simplicity of the solution.

(Simple drag&drop of video doesnât work at the forum here or? So I add two vimeo links.)

https://vimeo.com/251020613

https://vimeo.com/251020750

Train.3dm (942.3 KB)

Another issue I would like to ask about is, what would be a possible cause to make the IK view tree not display the IK chain even if youâve set it up?

If the chain is incomplete then it wonât show up, if youâre missing for example the goal.
Are you able to share the model so that we could have a look at it?