4 Replies Latest reply on Feb 9, 2017 1:48 PM by angelodc

    Highway Traffic Simulation

    angelodc

      Hello there. I'm working on a project in which I am animating a highway filled with cars. (For your convenience, I have included a style frame. You'll notice the cars are on the left side of the rode because my client is British.) Besides animating each car individually, is there a more economic way of populating the highway with flowing traffic? I welcome your ideas. Thank you.

       

      highway.jpg

        • 1. Re: Highway Traffic Simulation
          Szalam Adobe Community Professional & MVP

          You could look into using a particle effect of some kind.

          Particular lets particles follow motion paths.

          Foam lets you dedicate pathways too with a grayscale map to reference (precomposed, of course).

           

          Alternatively, you could animate one car on each path and use an expression like this to make a bunch of other cars follow it.

          • 2. Re: Highway Traffic Simulation
            A.I.1 Level 3

            You could select multiple cars then move them to animate them together (ie. move multiple cars in one go). Another idea: maybe a null layer with all the cars that are going in a straight line in one direction (set all of them to have their parent the null layer). That should also allow you to slightly vary the individual car speeds I think (ie. alter a few frames for individual cars, but move all that are going in a straight line with the null layer?).

             

            Another idea: (maybe a bit like Szalam's suggestion but without the expression): animate 1 car, then copy the keyframes to a layer for a different car, but select the keyframes and reposition them along the timeline (so each car in that lane follows the same path but so many frames later) - this should work even with the curved roadway. After copying and repositioning them along the timeline, you could slightly alter them to make different cars move slightly differently.

            • 3. Re: Highway Traffic Simulation
              Rick Gerard Adobe Community Professional & MVP

              I would draw a motion path for the cars in a lane, set a mask path keyframe, then copy it and then select car 1 in that lane, then press Alt/Option + p then Ctrl/Cmnd + v to make car 1 follow path 1.

               

              Now I would adjust the speed of car 1 by dragging the last position keyframe right or left.

               

              Then, if all of the cars in that lane were supposed to follow car 1 I would set up an expression for car 2 that used the index of car 1 (layer number) as a multiplier for time to offset car 2 in time so it stayed a constant distance behind car 1. I would then copy the expression only using the Edit>Copy Expression Only menu and paste it to the rest of the cars for lane 1. They will now all follow car 1 perfectly.

               

              If you want to have different speeds for different cars you can use the copied path for each car in lane one and paste it and adjust it for the other cars.

               

              If you really wanted to get creative you could add a slider to the expression. If the slider was attached to each car layer then you could individually adjust the speed of each car, but if you added a slider to a master controller layer, you could change the speed of all of the cars at the same time.

               

              I haven't got the time to write out the expressions for you and I don't want to try without taking the time to open up AE to make sure that they work but it's a pretty simple matter to figure out the right multiplier for the index and add it to the valueAtTime property for the first car's position.

              • 4. Re: Highway Traffic Simulation
                angelodc Level 1

                Thank you for your great answers! I think I'll do a mix of Gerard and AI1.