Answers.Body: <p>Expressions can only ever return one result. In your expression the two last lines both return a result, so the last one is what the value will be.</p>
  
  <p>Wiggle is a little bit confusing, in that it is not a function like Math.sin or random, that takes the value to be wiggled as a parameter. It is actually a method of the property, so when you call wiggle() in say, the position property, what you're actually calling is someLayer.transform.position.wiggle(). This returns a 'wiggly' value based on the value of the property, it doesn't actually change the value of the property itself. </p>
  
  <p>So to use the result of the wiggle expression in combination with other values you have to get the result of the wiggle expression, and use that in your final result. There is no need to add <code>value</code> to the wiggle result, because it is already added. Also, there is no point multiplying it by 1, that does nothing.</p>
  
  <pre><code>ctrl = thisComp.layer("diamond_control"); //just for neatness
  x = ctrl.effect("Horizontal")("Slider");
  y = ctrl.effect("Vertical")("Slider");
  
  wiggle_x = ctrl.effect("wiggle_x_pos")("Slider");
  wiggle_y = ctrleffect("wiggle_y_pos")("Slider");
  
  w = [wiggle(wiggle_x/100, wiggle_x/10)[0], wiggle(wiggle_y/100, wiggle_y/10)[1]];
  
  w + [x,y];
  </code></pre>
  
  <p>I'm not sure why you use the wiggle_x_pos and wiggle_y_pos slider for both the amplitude and frequency parameter of the wiggle. The first two values you give to wiggle are the amount of wiggliness and the frequency of the wiggle. Your expression would increase both frequency and amplitude together, that might be what you want. In the expression above this would then be added to the value given by the horizontal and vertical slider, which would be an offset, so that if x and y are equal to 0 the layer would wiggle around its base position. This seems a bit back-to-front.</p>
  
  <p>If you want a set of controls for the rest position, the amount and the frequency of the wiggle I'd set up the 'diamond_control' layer with two point expression control effects on it and one slider control. The adfvantage of using a point control is that you can control both parameters with a single control, right from the comp window. So given that setup you'd use this:</p>
  
  <pre><code>ctrl = thisComp.layer("diamond_control"); //just for neatness
  amplitude = ctrl.effect("Amplitude")("Point");
  basePos = ctrl.effect("Base Position")("Point");
  freq = ctrl.effect("Freqquency")("Slider");
  w = [wiggle(amplitude[0], freq)[0], wiggle(amplitude[1], freq)[1]) - value;
  
  w + basePos;
  </code></pre>
  
  <p>You can see that on the second line I subtract <code>value</code> from the wiggle result, this means that it just returns the wiggle offset, not the original base position. So that means the base position will be only set by the <code>Base Position</code> effect control.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-10T05:58:57.593Z
Answers.LastActivityDate: 2017-12-10T05:58:57.593Z
Answers.UserDisplayName: stib
Body: <p>So I have a null controlled named "diamond_control", I'm trying to control position and wiggle using sliders, separately. This is the code that I have come up with, but it doesn't seem to work. The penultimate line seems to be overwritten by the last line:</p>
  
  <pre><code>x = thisComp.layer("diamond_control").effect("Horizontal")("Slider");
  y = thisComp.layer("diamond_control").effect("Vertical")("Slider");
  
  wiggle_x = thisComp.layer("diamond_control").effect("wiggle_x_pos")
  ("Slider");
  
  wiggle_y = thisComp.layer("diamond_control").effect("wiggle_y_pos")
  ("Slider");
  
  [wiggle(1 * wiggle_x/100, 1 * wiggle_x/10)[0], wiggle(1 * wiggle_y/100, 1 * 
  wiggle_y/10)[1]];
  
  value + [x,y];
  </code></pre>
  
  <p>Is it not possible to control position and wiggle in one expression? </p>
  
  <p>Thanks in advance.</p>
  
Tags: <script>
Title: Combining wiggle with position AE
UserDisplayName: Jakub Mazurkiewicz
ThreadText: # Combining wiggle with position AE
  
  (Asked by: username_0 on 2017-12-10)
  
  So I have a null controlled named "diamond\_control", I'm trying to control position and wiggle using sliders, separately. This is the code that I have come up with, but it doesn't seem to work. The penultimate line seems to be overwritten by the last line:
  
  ```
  x = thisComp.layer("diamond_control").effect("Horizontal")("Slider");
  y = thisComp.layer("diamond_control").effect("Vertical")("Slider");
  
  wiggle_x = thisComp.layer("diamond_control").effect("wiggle_x_pos")
  ("Slider");
  
  wiggle_y = thisComp.layer("diamond_control").effect("wiggle_y_pos")
  ("Slider");
  
  [wiggle(1 * wiggle_x/100, 1 * wiggle_x/10)[0], wiggle(1 * wiggle_y/100, 1 * 
  wiggle_y/10)[1]];
  
  value + [x,y];
  
  ```
  
  Is it not possible to control position and wiggle in one expression?
  
  Thanks in advance.
  
  **Tags:** script
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-12-10. Score: 0 | Accepted answer
  
  Expressions can only ever return one result. In your expression the two last lines both return a result, so the last one is what the value will be.
  
  Wiggle is a little bit confusing, in that it is not a function like Math.sin or random, that takes the value to be wiggled as a parameter. It is actually a method of the property, so when you call wiggle() in say, the position property, what you're actually calling is someLayer.transform.position.wiggle(). This returns a 'wiggly' value based on the value of the property, it doesn't actually change the value of the property itself.
  
  So to use the result of the wiggle expression in combination with other values you have to get the result of the wiggle expression, and use that in your final result. There is no need to add `value` to the wiggle result, because it is already added. Also, there is no point multiplying it by 1, that does nothing.
  
  ```
  ctrl = thisComp.layer("diamond_control"); //just for neatness
  x = ctrl.effect("Horizontal")("Slider");
  y = ctrl.effect("Vertical")("Slider");
  
  wiggle_x = ctrl.effect("wiggle_x_pos")("Slider");
  wiggle_y = ctrleffect("wiggle_y_pos")("Slider");
  
  w = [wiggle(wiggle_x/100, wiggle_x/10)[0], wiggle(wiggle_y/100, wiggle_y/10)[1]];
  
  w + [x,y];
  
  ```
  
  I'm not sure why you use the wiggle\_x\_pos and wiggle\_y\_pos slider for both the amplitude and frequency parameter of the wiggle. The first two values you give to wiggle are the amount of wiggliness and the frequency of the wiggle. Your expression would increase both frequency and amplitude together, that might be what you want. In the expression above this would then be added to the value given by the horizontal and vertical slider, which would be an offset, so that if x and y are equal to 0 the layer would wiggle around its base position. This seems a bit back-to-front.
  
  If you want a set of controls for the rest position, the amount and the frequency of the wiggle I'd set up the 'diamond\_control' layer with two point expression control effects on it and one slider control. The adfvantage of using a point control is that you can control both parameters with a single control, right from the comp window. So given that setup you'd use this:
  
  ```
  ctrl = thisComp.layer("diamond_control"); //just for neatness
  amplitude = ctrl.effect("Amplitude")("Point");
  basePos = ctrl.effect("Base Position")("Point");
  freq = ctrl.effect("Freqquency")("Slider");
  w = [wiggle(amplitude[0], freq)[0], wiggle(amplitude[1], freq)[1]) - value;
  
  w + basePos;
  
  ```
  
  You can see that on the second line I subtract `value` from the wiggle result, this means that it just returns the wiggle offset, not the original base position. So that means the base position will be only set by the `Base Position` effect control.
  
  
  ---
  
  