Home Forums After Effects Expressions Explore the wiggle() Expression

Viewing 0 reply threads
  • Author
    Posts
    • Nubby Ninja
      Keymaster
      Post count: 13

      Wiggle.aep contains 3 comps.

      I started with the simplest version.

      Select the layer you want to want to affect, hold ALT and click the property you want to apply the wiggle() expression to.

      wiggle(2,30);

      2 being the frequency, or times-per-second to wiggle.
      50 being the amplitude, or amount to move (in this case, pixels).

      This worked. I wanted more control though. So, I separated the X and Y position.
      “org” is x
      “temp” is y

      I gleaned this from elsewhere on the internet, but I don’t recall the original source. Feel free to leave a comment with that info and I’ll be sure to add it to the Project.

      org=value;
      
      temp=wiggle(2,40);
      
      [temp[0],org[1]]

      ___________________________

      So far we’ve assigned the wiggle() expression to only affect the y position.
      Now, I want a little more control over the different values in the wiggle() expression.

      You might find similar code out there, but this I crafted myself:

      x=value;
      
      y=wiggle(thisComp.layer("Shape Layer 1").effect("Y-Wobble Frequency")("Slider"),thisComp.layer("Shape Layer 1").effect("Y-Wobble Amplitude")("Slider"));
      
      [y[0],x[1]]

      So x is assigned whatever value you leave it at. So “value;” accounts for this.
      The y position is assigned the wiggle() expression, but instead having to go back and change the frequency and amplitude from the expression itself (adding the risk of fudging the script each time) I connected both values to sliders. (expression controls).

      I made sure to label the sliders appropriately. Don’t get confused between the slider names and the call to (“Slider”)… this is calling to a specific line in the control. The theory is that you can add more properties through JavaScript to these expression controls, so by default this one is called slider. Down the road I will learn how to control the names of the different properties.

      At the end of the code, we assign the the variables X and Y to the different position values. That part is required for the code to function, otherwise the expression will point to nowhere.

      [y[0],x[1]]

      Often in various programming / scripting languages, the first iteration when referring to any object, parameter or property in-sequence is 0… the second is 1, and so on.

      So since Position in After Effects starts with y, it gets a value of 0 (zero) and since x is the next iteration, it gets a value of 1.

      This is the order of things. Believe me, it took a few minutes for my brain to break out of the X then Y mentality. When in Rome.

      Attachments:
      You must be logged in to view attached files.

      Nubby Ninja

Viewing 0 reply threads
  • You must be logged in to reply to this topic.