ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change object size at certain time and make it stick

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rasmus Hansen
Change object size at certain time and make it stick
on Aug 20, 2019 at 7:48:26 pm

Hi there,

I'm making a lava lamp emulation, and since the end result should be about an hour long, it's too time consuming to keyframe everything. Therefore, I decided to give expressions a go. Through a lot of studying (thanks, Dan!) and trial and error, I managed to come up with something that works okay.

What I now want to do is to be able to change the size of the lava blobs, to a random size, whenever the blobs hit the bottom (posDown in the code below). And then KEEP that same size until the next time it reaches posDown. Alternatively, give a random x position when the blobs hit the bottom.

Is that even possible? I played around with using random() on the size property, but it's changing the size at random at every frame - and if I use seedRandom, it always changes to the same size at every loop. Moreover, I can't get it to stay at that size.

Any help is much appreciated.

Thanks in advance.

POSITION Y EXPRESSION
---------------------------------
seedRandom(index,true);
blobSize = content("Ellipse 1").content("Ellipse Path 1").size[0];
holdDur = random(2,8);
moveDur = linear(blobSize,100,800,10,40);
posUp = -blobSize*0.5;
posDown = thisComp.height+blobSize*0.5;

t1 = holdDur;
t2 = t1+moveDur;
t3 = t2+holdDur;
t4 = t3+moveDur;

t = time % t4;

if (t &lt; t1){
posDown
}else if (t &lt; t2){
easeOut(t,t1,t2,posDown,posUp)
}else if (t &lt; t3){
posUp
}else{
ease(t,t3,t4,posUp,posDown)
}

POSITION X POSITION
------------------------------
seedRandom(index,true);
xPosRand = random(thisComp.width);
xPosWig = wiggle(0.2,200);
xPos = xPosRand + xPosWig - thisComp.width*0.5;

[xPos]


Return to posts index

Rasmus Hansen
Re: Change object size at certain time and make it stick
on Aug 20, 2019 at 7:48:49 pm
Last Edited By Rasmus Hansen on Aug 20, 2019 at 7:50:03 pm

What I have now looks like this:


drive . google . com / open?id=1RCBxJ0UQMhN7kbiFb_7vi_ZfNht1BbXI


Return to posts index

Rasmus Hansen
Re: Change object size at certain time and make it stick
on Aug 31, 2019 at 10:30:27 am

Does anyone know if this is somehow possible? :)


Return to posts index


Dan Ebberts
Re: Change object size at certain time and make it stick
on Aug 31, 2019 at 8:43:16 pm

It's definitely possible, but somewhat complicated. The issue is that each cycle will have a different duration and since expressions have no memory, the expression will have to reconstruct everything that has occurred in the past. This is a rough attempt at the Y Position expression. It might not be quite right, but it should give you the idea of what you need to do to construct a solution:

Dan

blobSize = content("Ellipse 1").content("Ellipse Path 1").size[0];
moveDur = linear(blobSize,100,800,10,40);
posUp = -blobSize*0.5;
posDown = thisComp.height+blobSize*0.5;

tCur = tPrev = 0;
cycle = 0;
while (tCur &lt;= time){
seedRandom(cycle,true);
holdDur = random(2,8);

t1 = holdDur;
t2 = t1+moveDur;
t3 = t2+holdDur;
t4 = t3+moveDur;
tPrev = tCur
tCur += t4;
cycle++;
}
if (time >= 0){
t = time - tPrev;

if (t &lt; t1){
posDown
}else if (t &lt; t2){
easeOut(t,t1,t2,posDown,posUp)
}else if (t &lt; t3){
posUp
}else{
ease(t,t3,t4,posUp,posDown)
}
}else
value




Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]