How to animate train to follow a path

Hi,

I'm trying to animate a train car to follow a path. I've created the actors; train car, leading axle and trailing axle. I've attached the train car to the leading axle and the trailing axle to the train car. I've then defined the leading axle to follow a path and given a specified time so I can see it in motion. Issue here is that when I run the script, on curve path, the trailing axle will be thrown out of the path.

How do I move the trailing axle so that it will follow behind the leading axle following the same path and thus rotate the train car accordingly (similar as how a train car moves in reality)?

Thanks in advance,

Lina

Parents
  • I think your best bet would be to attach all three actors to the path using path distance method so all are moving along path at same speed the the axle actors will align to the rail. I set your Actors to all be traveling at 18*tSeconds or 18 Meters per second which is 64.8K per hour you can adjust this to be the speed you need.

    We plan to make it easier to animate trains in the future.

    Cheers,

    Jerry

    train.dgn
  • Thanks Jerry,

    I've noticed when I run the script that the axles run out of the original 1600mm position when going around curves. I've managed to settle that by playing around with the timing of the two axle.

    Then I've noticed that the horizontal line of the train car is not in line with the mid-of axles when going around the curves.

    Any suggestion as to how to get the train car to move and rotate based on the 2 mid-of axle position? In other words, the train car is moved and/or rotated based on the position of the 2 axles mid point.

    Thanks,

    Lina

  • Good one Ron I was thinking to give this a shot it is similar to how I animated the tractor trailer rig in my animation book but to be honest was too slammed with a million other things. Thanks for helping Lina out.

    Cheers,

    Jerry

  • Hi Ron,

    I'm trying to replicate what you have done, but somehow I can't. I've created the axle actors with origin at centre, I've created train actor with origin at the rear axle. I've attached the train to the rear axle. I've defined actor path for the 2 axle. And last but not least I've used the Script Target with target activated on, train as object and front axle as target. But when I run the script, the car would just detach itslef and run on it's own. Is there any thing that I've missed out? I've tried doing this in 3d; same effect.

    How'd you do it?

    Lina

  • When you create the train box car actor you need to rotate the actor's origin such that it's Z axis (blue weighted line) is pointing away from the front wheels. If you open Ron's example you will see this in the front view.

    Cheers,

    jerry

  • Wow! Thanks guys! Finally got my simulation to work! Didn't know that the actor's origin makes a big difference. Mind explaining why is this so? I thought the car body moves in the same axis as the axle...

    By the way, the axle still did not maintain the same distance apart when running the script. But I guess this is a good start.

    Thanks a lot,

    Lina

  • Nice one Ron,

    Lina,

    The Target Tool is designed to work with Camera. With the Camera as object ,the  Z axis of the Camera ( which is in the direction of Camera view) needs to points at the target. Thats the reason why we need to set the Z of the object ( box) pointing to the target ( front wheel).

    Rg,

    Nilesh



Reply Children
  • I forgot to mention that I also struggled with the Z-axis issue when I setup the example.

    It would be nice if the targeting axis for non-camera actors could be selected when targeting rather than having it default to Z. Using the Z-axis for targeting makes sense for a camera because it's axes are fixed, but other actors axes aren't fixed and may have been defined without considering targeting.

     

    Lina,

    To get the wheels to maintain a constant distance be sure to check the Path Distance box when you define the actor, and define the speed (distance per second) as shown in the image below. If you use the same equation for each axel, and  the same start and end times for each axel, they will both move along the path at the same speed. 

     

     -Ron