7 Replies Latest reply on Jul 21, 2016 9:22 AM by Rick Gerard

    Moving an insect...


      Hello guys,


      I'm really looking for your insights on how to accomplish this movement in after effects. It's pretty simple but probably requires the right expression.

      I am animating an insect walking, shot from above. It has to look very realistic.

      I already shot the insect in macro on a blue screen, and have its walk looping perfectly in a 1 second comp.

      Now I need it to follow a bezier path, so it looks like it's walking on the ground that will be layered beneath it.


      The thing is, the way insects walk is not a constant position change. This would look like the insect is sometimes floating (like in cheap cartoons). Instead, it will move 20 pixels forward along with its right legs, then stop moving forward for a few frames (the time it takes for its left legs to reach in front of him), then move again 20 pixels forward along with its left legs, then pause again, etc... It's like move position 20 pixels over 5 frames, stop 5 frames, move position 20 pixels again, stop 5 frames, over and over.


      I am trying to find a good work flow, to have this start/stop motion looped (without having to draw the whole thing manually), as the insect comp follows the bezier curve I drew.


      Please share your insights on how to achieve this.


      As we say here in the Philippines, salamat po (respectfully thank you!).



        • 1. Re: Moving an insect...
          Roei Tzoref Adobe Community Professional

          how about Good Ol' Motion Sketch? you can record the movement as you move your mouse. there is flexibility as you can set, prior to your recording, smoothing and recording speed (you can also smooth after with the smoother or an expression) here is a similar example of a fly. check him out!


          • 2. Re: Moving an insect...
            Mylenium Most Valuable Participant

            It's pretty simple but probably requires the right expression.


            Not really. There is no way to access all aspects of keyframes with expressions like their tangents, so there is no way to use that info. All you ever get is the actual interpolated value using valueAtTime(), the rest AE will do for you. That said, even if it were possible, reconstructing the entire path inside the expression would not be trivial and then you'd have to throw the animation timing on top of it based on calculating the actual path lengths. So rather than looking for convoluted solutions like this, just keyframing it would be a lot quicker.



            1 person found this helpful
            • 3. Re: Moving an insect...
              Baobaob Level 1

              OK Mylenium. I didn't realise telling the comp to follow the bezier for 5 frames then to stop for 5 frames in a loop could turn out to be such a challenge for After Effects

              Too bad, as you suggested, I'll just keyframe it manually I guess... I was hoping to also control the speed it goes along the path with a slider, but I suppose that will be for AE Creative Galaxy 2078 because clearly that would be such a futuristic thing to even think of...!

              • 4. Re: Moving an insect...
                Rick Gerard Adobe Community Professional & MVP

                I would approach this problem a little differently. If I understand you correctly you have basically created a walk cycle for your insect. Your desire is to make the moving legs match the movement along the ground so the legs don't look like they are slipping or the insect floating.


                I have done this kind of thing quite often for everything from tires rolling on the ground to cartoon characters walking around a virtual set but I don't try and keyframe position to match movement I match movement to position. Let me explain.


                Say you have a five frame walk cycle so your character - your bug - moves it's legs in one complete walk cycle in 5 frames. So far the only thing moving is the legs. If you nest a copy of your character in a new comp you can then use time remapping to control the speed of the moving legs. It's pretty easy to figure out how far the character would move for one walk cycle. Let's say that when the character layer is at 100% scale the main legs move 50 pixels in the first half of the walk cycle. In other words, in the case of a bug with six legs, the right front leg starts on the ground and moves back 50 pixels, then the right front leg comes off the ground and moves forward 50 pixels and repeats. Each step should then move the character forward 50 pixels. Now that you have that figured out it becomes a pretty easy thing to use time remapping in  conjunction with position vectors to make the movement of the legs match the speed of the walk cycle. Move the character layer slowly and the legs move slowly, move the character layer quickly and the legs move quickly. You use vector math and tie the speed of the layer to the frame rate of the time remapping. Once you have that worked out you can use motion sketch or any other method to keyframe position and the animation of the legs will match up so your character will be stuck to the ground in a realistic way. Throw in scale or get really fancy and add in 3D layer properties and distance from the camera and this will still work perfectly.


                I won't give you the expression for moving anywhere on the stage at any scale but here's a thread and an expression for matching a walk cycle to x position: Motion blur and looping a character walk cycle

                1 person found this helpful
                • 5. Re: Moving an insect...
                  Baobaob Level 1

                  Hi Rick, and thank you for your very detailed and interesting approach. I really appreciate your insights.


                  I haven't been able to figure out everything you said exactly yet, I've been reading it over and over for the past hour doing some tests


                  One of the things I'd appreciate more detail about, is this part:

                  use time remapping in  conjunction with position vectors to make the movement of the legs match the speed of the walk cycle


                  Also, in my case, one comp loop of the walk lasts 01:17 (47 frames) because I kept 3 walk cycles, to have a bit more "random" than one single loop.


                  Still not sure how to make the insect move forward in steps instead of regularly, and then have this follow a bezier line this way, without having to keyframe everything...

                  • 6. Re: Moving an insect...
                    Roei Tzoref Adobe Community Professional

                    Rick thank you for sharing the expression!  Baobaob I believe you need to look at this response of Rick: he even kindly shares an Aep File. the spatial movement of the whole spider in the master composition is the easy part, what is suggested here is that you connect the position value to the timeremapping via expression that measures the stride of the spider so when you move it in the composition window it will auto-magically move it's legs accordingly. there's math involved here but you have a project file. the moving part is easy - if you want it to follow a specific path you can paste the path to the position. or do it more randomly with Motion Sketch.

                    1 person found this helpful
                    • 7. Re: Moving an insect...
                      Rick Gerard Adobe Community Professional & MVP

                      When you synchronize the walk cycle to time remapping all you have to do is keframe in the position and the legs will move exactly the way you want them to move.


                      The example I gave is extremely simple and only calculates movement on the X axis.  The expression that uses velocity is a lot more complex. I have not decided whether to give that away as an animation preset because it is part of a package that I am about to put on the market.  It is more than possible to use something as simple as motion sketch to animate the path and speed of your bug and keep the stride in sync by adding the right expression to time remapping.  It takes nothing more than the math that is available in the expression language menu and a good understanding of geometry to create the expression that synchronizes stride with the position direction and velocity.