Mailing List AE-List@media-motion.tv — Message #65919
From: Nathan Shipley <AE-List@media-motion.tv>
Subject: Re: [AE] Repelling layers
Date: Mon, 20 Jan 2020 09:30:08 -0800
To: After Effects Mail List <AE-List@media-motion.tv>
At that point you’d probably want to just use something like the Newton plugin which is built for this kinda stuff.  It would be a bad use of expressions, get complicated, and probably bog down pretty quickly since expressions don’t have a “memory” as Dan Ebberts puts it.  That is to say, they only know what is going on in the current frame and you have to build in kinda slow workarounds to deal with this; there are no persistent variables, which you’d want to build a physics system. 

Good question though!

On Mon, Jan 20, 2020 at 8:22 AM D <AE-List@media-motion.tv> wrote:
…I should say 'make the grey blocks collide with each other’ as opposed to repel each other.

On Monday, 20 January 2020, D <dow.hanson@gmail.com> wrote:
> Excellent Nathan.
>
> Is it possible with expressions to make the grey blocks repel each other too? (i’m not asking you to do it, I’m just interested whether it’s possible with expressions).
>
> Thanks.
>
> On Thursday, 16 January 2020, Cary Spenser <AE-List@media-motion.tv> wrote:
>> Nathan -
>> Really helpful to rocket my understanding of scripting. 
>> Thanks!
>> Cary
>> On Wed, Jan 15, 2020 at 1:15 PM Nathan Shipley <AE-List@media-motion.tv> wrote:
>>
>> Henry,
>> Here's something really basic I just whipped up that simply moves layers away from a null.  It just pushes objects away from where the null is when they're closer than the "Distance Threshold" control.  You can increase the amount that they move with "Move Away Multiplier."
>> Just paste the position expression from one of the solids to your own layers and it should work or at least be a starting point to tinker further.  Expression pasted below as well:
>> Here's a quick screencapture showing what it does:
>> https://www.dropbox.com/s/97yymslvdmjgeez/MoveAwayDemo_01.mp4?dl=0
>>
>> And here's the .AEP:
>> https://www.dropbox.com/s/8g3scef520fir3r/MoveAwayExpression_NS_01.aep?dl=0
>>
>> Not fancy but maybe helpful?
>>  - Nathan
>> p = transform.position;
>> nullPos = thisComp.layer("Parent And Controls").transform.position;
>> distanceThreshold = thisComp.layer("Parent And Controls").effect("Distance Threshold")("Slider");
>> moveAwayMult = thisComp.layer("Parent And Controls").effect("Move Away Muliplier")("Slider");
>>
>> distance = length(p, nullPos);
>>
>> if (distance < distanceThreshold) {
>>     distanceMult = (Math.log(distanceThreshold / distance)) * moveAwayMult;
>>     delta = nullPos - p;
>>     nDelta = (normalize(delta));
>>     newPos = p - nDelta * distanceMult;
>> } else {
>>     p
>> }
>>
>> On Wed, Jan 15, 2020 at 9:13 AM henry birdseye <AE-List@media-motion.tv> wrote:
>>
>> This is true.
 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster