System for creating particle effectors in After Effects using expressions
eTractors
is a way to create 'effector' layers that can attract and repel other layers when they move within a specified distance.
It comes in the form of a JSON file that's imported into the project, and then referenced in expressions.
This aeFunctions is compatible with After Effects versions >= 16.0.1 (CC2019) which use the new Javascript engine.
Example layer attraction setup using eTractors:
// Import the library
const eTractors = footage('eTractors.jsx').sourceData;
effectorLayer = thisComp.layer("eTractor");
particlePosition = transform.position
effectorRadiusMultiplier = 10; // Enlarge Whole Effect Area
effectorLayerEffectSize = 150; // Set The size of the effector when the strength is maximum from 0 a point to larger as an ellipse
// Create a new effector
const myEffector = eTractors.createEffector(effectorLayer, particlePosition,effectorRadiusMultiplier,effectorLayerEffectSize);
// Move towards attractor
power = myEffector.strength * 100;
value + [power,power]
Download the eTractors.jsx
file from the master branch of this repository, and import it into your After Effects project.
aeEffector is designed to be used on the 2D position property of a layer, and this is assumed by all of the following expressions.
To reference the library in an expression, you need to assign it to a variable. This is done via the line:
const eTractors = footage('eTractors.jsx').sourceData;
β οΈ Since After Effects doesn't count footage items that are only referenced within expressions as used, it's recommended that you also place theeTractors.jsx
file in any compositions where it is referenced.This will ensure After Effects includes the file when collecting assets or packaging into a Motion Graphics Template.
This creates a new effector based on an effector layer, and the position of the current layer.
const myEffector = eTractors.createEffector(effectorLayer, particlePosition, effectorRadiusMultiplier, effectorLayerEffectSize);
The createEffector
function returns an object with a couple of properties you can use to influence the motion of your particle layer.
effectorRadiusMultiplier
increases the reach of the effector
effectorLayerEffectSize
is the size of the area that the effect as at maximum strength. 0 default is a maximum strength of a point, where if we set it to 100 then the maximum effect strength occurs within 100 pixels of the attractor position
// Move towards attractor
particlePosition + myEffector.attract;
// Move away from attractor
particlePosition + myEffector.avoid;
This project is licensed under the terms of the MIT License.
Bugs, issues and feature requests can be submitted by filing an issue on Github. For everything else, feel free to reach out to @modeveloper on twitter.