> For the complete documentation index, see [llms.txt](https://frangiordano96.gitbook.io/ae-expressions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://frangiordano96.gitbook.io/ae-expressions/after-effects-expression-global-wind-controller.md).

# After Effects Expression - Global Wind Controller

### Full step by step Tutorial:

{% embed url="<https://www.youtube.com/watch?v=FYLpC9FTmDM>" %}

Code for ***Bend*** property:

```javascript
let windSpeed = thisComp.layer("WIND CONTROLLER").effect("wind speed")("Slider");
let indexByPos = linear(position[0], 0, thisComp.width, 0.7, 1.7);

Math.sin((time-indexByPos)*Math.PI*windSpeed/10)*windSpeed*2;

/*
Expression by Francisco Giordano, August 2020.
Free for personal use and commercial use.
Instagram @ae.fran.giodano - frangiordano96@gmail.com
*/
```

For the Start and End properties, you'll have to apply different expressions depending on the type of your layer:

{% tabs %}
{% tab title="If your layers are vectors" %}
Code for ***Start*** property:

```javascript
transform.position
```

Code for ***End*** property:

```javascript
[position[0], position[1]-thisComp.height/2];
```

{% endtab %}

{% tab title="If your layers are images" %}
Code for ***Start*** property:

```javascript
let myRect = sourceRectAtTime();
[myRect.width/2, myRect.height];
```

Code for ***End*** property:

```javascript
let myRect = sourceRectAtTime();
[myRect.width/2, -myRect.height];
```

{% endtab %}
{% endtabs %}

Code for ***Rotation*** property:

```javascript
let windDirection = thisComp.layer("WIND CONTROLLER").effect("wind direction")("Angle");
let indexByPos = linear(position[0], 0, thisComp.width, 0.5, 1.5);
let windSpeed = thisComp.layer("WIND CONTROLLER").effect("wind speed")("Slider");

let sinRotation = Math.sin((time-indexByPos)*Math.PI*windSpeed/10)*windSpeed/2;
let windRotation = linear(windDirection.valueAtTime(time-indexByPos), 90, -90, windSpeed, -windSpeed);

sinRotation + windRotation;

/*
Expression by Francisco Giordano, August 2020.
Free for personal use and commercial use.
Instagram @ae.fran.giodano - frangiordano96@gmail.com
*/
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://frangiordano96.gitbook.io/ae-expressions/after-effects-expression-global-wind-controller.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
