Skip navigation

Today’s task was to create boxcars that follow the engine and each other in turn. Once again I had to catch myself from making the problem too difficult.  I set up a test scene that I could quickly iterate on (instead of having to place track and stations and buy a train every time I wanted to test).  That was smart.  This was dumb:  I started out by trying to make the boxcars behave like real physical objects that have a forward and backward attachment point and tried to “figure out” where they were on the track based on the boxcar (or engine) they are attached to.

After floundering with that for a while I had a thought: I have the engine working correctly, why not just have each boxcar behave like the engine but delay it the correct amount of time before sending it down the track after the engine.  A little bit of programming later I had a much simpler solution and it looks great.


Please excuse the height miss-match.  I will fix that later as I polish the train code.  I think I might have each boxcar fade in as it pulls out of the station…

Leave a Reply

Your email address will not be published. Required fields are marked *