ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trouble With Creating A Rollover Properly

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Erik Heathcote
Trouble With Creating A Rollover Properly
on Jan 31, 2019 at 8:43:19 pm
Last Edited By Erik Heathcote on Jan 31, 2019 at 8:53:19 pm

Hello friends! I'm still a bit new to expressions and I feel like I'm missing something obvious and can't seem to figure out what it is. I'm trying to see if I can figure out how the kind of animation seen in this little loading type loop works: https://gyazo.com/f89a827d24bbf439220c714056445c27

I've managed to get the rollover effect working using this code


sMax = thisComp.layer("Center").effect("Scale")("Slider");
radius = thisComp.layer("Center").effect("Radius")("Slider");
a = thisComp.layer("Center").transform.position[1];
b = position[1];

l = length(a, b);
s = ease(l, 0, radius, sMax, 0);
[s,s]


Which I currently have looking like this in my comp: https://gyazo.com/a5858a36c50fb1f77837c0869a9ca535

The trouble is that while the shapes are scaling they aren't sticking to the other shapes. In the original as the shapes scale, the edges where they touch never separate like they're all in a chain with each other. In asking some other mograph friends they suggested using an expression I hadn't heard of before called sourceRectAtTime and after trying to figure out how I would define it in my comp I can't seem to work it out so they interact as expected. All I've got in my comp is a series of shape layers all in a row vertically and then the null passing over them doing the rollover with the above code. What am I missing to get them to be 'linked' to each other as they scale? I'm not quite sure how to get them each to reference each other right with sourceRectAtTime if that's the right expression to be using here.


Return to posts index

Erik Heathcote
Re: Trouble With Creating A Rollover Properly
on Feb 1, 2019 at 12:44:38 pm

Okay, so I've tried some other things and I'm a little closer to what I am looking for but still not quite. I figured out how to get the shapes to all 'stick' to each other along the edges using the dynamic resizing explained here:



so now I've got my row of shapes, with the nulls controlling their scale based on the position of the null

https://gyazo.com/95148ff8f706772905c110d7c03b4bad

And, they're all sticking properly to each other since moving a null between them up and down properly scales the two shapes accordingly as seen here so they never stop touching: https://gyazo.com/35e08df05c3ea5907e350b1b6f7209e0 Each shape has code like this:

p1=thisComp.layer("11").transform.position;
p2=thisComp.layer("12").transform.position;
Delta=p1[1]-p2[1];
s=(Delta/85)*100;
[s,s]


For each shape p1 and p2 reference the appropriate null on either side of the shape and the number value of the divisor in the s variable changes depending on how tall the shape is so the code outputs 100,100 for the scale in the default position.

Now the tricky part is figuring out the rollover so it looks like this as the row of shapes go up and down https://gyazo.com/f89a827d24bbf439220c714056445c27

Cause these nulls are controlling the scale based on their position from each other so the edges are always touching. But the scale also needs to be controlled based on the distance from the master null in the middle in an arc of sorts so they're at 100% scale as they pass under that and ease away in scale to 0 on either side. I'm trying to wrap my head around what that would even look like and am running into a wall. I feel like it's going to end up being a pretty gnarly expression to make sure everything is factored in right but I'm not quite sure how to get what I have now to behave that way.


Return to posts index

Erik Heathcote
Re: Trouble With Creating A Rollover Properly
on Feb 1, 2019 at 1:36:42 pm

So here's a thought, is there a way to make a series of things move like they are connected together by a set length of chain? So in my comp I currently have it set so that the position of the controller nulls is clamped at 340 and 740 so that those are the points where the shapes they are controlling scale to zero on either side.

Let's say all the nulls are currently on top of each other at 740y. All the nulls in the stack are connected together by a set 'chain' of distance that is the max apart they can be. So null1 to null2 can be a maximum of such and such distance, null 2 to null3 such and such distance and so on. While they're all sitting on top of each other the chain is 'slack' per se and if I grab null1 and start scooting down towards 340y once it gets the length of the chain from null2 away it starts pulling null2, and then when null2 is a set length away from null3 it pulls that and so on. All until they've all pulled each other down in sequence to 340y kind of a cascading sort of thing. So basically because of the way the nulls are connected to each other with these chains and because the distance between the nulls controls the shape scaling it should do the look I'm thinking of where the scale is zero on one side, scales up to 100 as it goes across the middle as the chain goes 'taut' between the nulls, and then back down to zero again on the other side as the next null is catching up to the first null making the chain more 'slack' (and therefore also decreasing the size of the shape). Is that doable?


Return to posts index


Kalleheikki Kannisto
Re: Trouble With Creating A Rollover Properly
on Feb 3, 2019 at 12:04:35 pm

As I see it, you will need to multiply the distance of the nulls from the point where they are enlarged, along the lines of the following image.



"Distance" here would be the distance between a given null and the point where the enlargement happens (whether it be a static point or another null that controls that location). "Multiplier" would be the multiplier (from 1 to maximum enlargement) with which that distance is multiplied to get the nulls to spread out near the point of enlargement.

Now, since the nulls need to move together, you'd start the expression with a simple fixed offset from a master null (like the first null in the string). Then you'd use the multiplier to change the distances. A piece of sine wave between two flat sections should work for the formula, which I'm not going try and guess at here.

Once the motion of the nulls looks good, then you can set the objects to scale to fill the distance between the nulls.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Erik Heathcote
Re: Trouble With Creating A Rollover Properly
on Feb 3, 2019 at 6:19:51 pm

Well, after a lot of banging my head on the wall I finally figured something out that worked. https://dribbble.com/shots/5953038-Loading-Roller

For anyone who happens across this thread in the future here's how.

Alright so just take these three shapes for example which start full size and then scale down as they go towards the top of this 250 pixel tall comp https://gyazo.com/5e697088ab0350d112ac6b2c06afc195

I've got a master null with a slider on it that controls everything. On the pink triangle the y position has
s=thisComp.layer("MasterRoll1").effect("UpRoll")("Slider");
clamp(s,0,250);


and the scale

s=thisComp.layer("MasterRoll1").effect("UpRoll")("Slider");
ss=linear(s,0,-96.07,0,100);
[ss,ss]


The 96.07 being the height of the triangle. And when I do the next shape down you just factor in the shape before it in the sequence
So the grey oval on the y position and scale are

s=thisComp.layer("MasterRoll1").effect("UpRoll")("Slider")+96.07;
clamp(s,0,250);


and

s=thisComp.layer("MasterRoll1").effect("UpRoll")("Slider")+96.07;
ss=linear(s,0,-57.77,0,100);
[ss,ss]


and so on for all the shapes in your chain

To do the ones coming from the bottom I just added another slider to my null and made its value be the value of the first slider+size of the comp (in this case 250) and then when I did the shapes coming from the other direction pickwhipped them to the second slider and adjust the values according for their sizes.

So to animate it at the end all I had to do was move the first slider between -250 and 0 and it drove everything.

And do get the different sequences of 3 shapes I just had the layers end when they disappeared and the corresponding layers the other direction appear for the rollback. Each set of shapes added up to 250 pixels tall

https://gyazo.com/3be8d93d5006524028dbe34bf331ce13


Return to posts index

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