Menu

Tutorial 186: Behaviors

Joe Clay | Jul 26, 2019

In this week's After Effects tutorial, we explore building a Cinema 4D-like effector by setting up behaviors based on positioning of layers. In our first example of a very wildly inaccurate Apollo mission example, we use distance to illustrate a burn of the Command Module. I also mentioned that this was inspired by the 50th anniversary of the moon landing an the new Apollo 11 (2019) documentary. There's some amazing footage in there that was recovered, and I believe it's a lot of never-before-seen footage. It was painstakingly put together, and the result is excellent.

Anyway, we continue on to make objects scale as another object approaches and finally we make a space ship capable of matter rejection. What's that you ask? It's the ability to force objects to stay outside of a predefined perimeter. There's not asteroid that can touch our ship.

There are a ton of things that can be done with this technique. You're really only limited by your imagination and ability to code. We've already covered distance and angle, so you have a good base to start from!

Expression Code

This is the more basic code from the tutorial. It covers distance only.

d = length(thisLayer.position, thisComp.layer('Moon').position);
s = ease(d, 100, 300, 80, 30);
[s, s];

This is the more complex code from the tutorial. It covers distance as well as angle.

r = effect("CC Sphere")("Radius") + thisComp.layer("Controller").effect("Shield Radius")("Slider");
ptA = thisLayer.position;
ptB = thisComp.layer('Zeus Orb').position;
d = length(ptA, ptB);
if(d < r) {
    x = ptA[0] - ptB[0];
    y = ptA[1] - ptB[1];
    a = Math.atan2(y, x);
    x = Math.cos(a);
    y = Math.sin(a);
    r = r - d;
    value + [x*r, y*r];
} else {
    value;
}

Grab the Project Files

Get the project file through our Gumroad Store. This project file contains the setup shown in the tutorial along with the textures, overlays, and other elements used in the thumbnail. The After Effects project was built in AE CC 2019 but a version was saved that will open in v14 (2017). It shouldn't have any issues with either expression engine.

If you're buying project files, consider becoming a Patron. At the $5/mo. tier, you get access to project files as they come out and some tutorials also come with additional BTS content showing more of the builds.

Get the project on Gumroad

Become a Patron

If you'd like to help support Workbench, check out our Patreon page. Thank you for even considering clicking this link to support what we're doing. We appreciate it. Patrons get all sorts of benefits, from additional files to early product releases depending upon the tier.

Check out our Patreon Today