Jump to content
Sign in to follow this  
christianchoice

Expression & Variables!

Recommended Posts

i dont think AE allows global variables, you could use an expression controller slider etc as a holder for that value

 

hmmm...

 

well the thing is, it's going to be a cascading effect involving over 100 layers. I want the layer below to read a specific value from the layer above...

 

it's not a huge deal, i'll just have to manually encode the specific values....

Share this post


Link to post
Share on other sites
hmmm...

 

well the thing is, it's going to be a cascading effect involving over 100 layers. I want the layer below to read a specific value from the layer above...

 

it's not a huge deal, i'll just have to manually encode the specific values....

 

go on creative cow, dan ebberts is the man with helping people write custom expressions

Share this post


Link to post
Share on other sites
go on creative cow, dan ebberts is the man with helping people write custom expressions

 

You don't need global variables (which AE doesn't allow for a few reasons) for this.

You can sample from the layer above by using something like:

 

layer(index-1).propertyName, etc.

Share this post


Link to post
Share on other sites

While on the topic, there's a little known workaround for global variables, which is "#include"

 

On a Mac, you can use:

 

#include '/expressions/source.txt'

 

For a file located in a folder called "expressions" at the root of your drive, in a text file called "source".

 

On Windows, you'll need something like this:

 

#include 'file:///c:\\expressions\source.txt'

 

In that file, the syntax will be treated just like an expression. So, you can put something like:

 

gVar = 10;

 

And then use that include statement in each layer, and then 'gVar' will kinda sorta be a global variable that you can change in one place. For this particular solution, I can't really tell if this will be useful or not. Perhaps you could define a slew of variables in one place to save time? Just a guess.

Share this post


Link to post
Share on other sites

I'm animating a magazine with flipping pages.

I'm trying to control the page turns with one controller.

 

The theory is to wait for the other page to complete it's turning before this one can turn. Thus this angle limits. These will change as the revolutions go up in the global controller.

 

If someone has another idea, that would be great :).

 

I will try that #include statement. I was wondering if AE did that. Thanks graymachine.

 

//Sets the layers above & below for future referencing.
layerAbove = thisComp.layer(index-1);
layerBelow = thisComp.layer(index+1);

if((layerAbove.transform.yRotation==(0||180))||layerBelow.transform.yRotation==0)
  {
 if(thisComp.layer("Null 1").effect("Angle Control")("Angle")<=360)
    {
  0;
     }
else if(thisComp.layer("Null 1").effect("Angle Control")("Angle")>=540)
     {
  180;
     }
else
     {
      thisComp.layer("Null 1").effect("Angle Control")("Angle");
     }
  }
else
  {transform.yRotation=0;}

Share this post


Link to post
Share on other sites
I'm animating a magazine with flipping pages.

 

*snippeted*

 

Wrong approach and methodology. You don't need any global variables at all, so get this notion out of your head. You also don't need any conditionals. Just animate a prototype layer, then use valueAtTime() to trigger the other layers' properties. For variation, you could even add a multiplier to the time. Having a complete cycle is made sure by setting proper start and end keyframes to begin with...

 

Mylenium

Share this post


Link to post
Share on other sites
Wrong approach and methodology. You don't need any global variables at all, so get this notion out of your head. You also don't need any conditionals. Just animate a prototype layer, then use valueAtTime() to trigger the other layers' properties. For variation, you could even add a multiplier to the time. Having a complete cycle is made sure by setting proper start and end keyframes to begin with...

 

Mylenium

 

so animate one layer.

then set the other layers rotation to valueaAtTime()?

 

but i need to be able to control the speed of the flips. I need to be able to pause on a page, then go to the next one, etc.

I used another method that doesn't need a global variable... It works, but if you think your method would still be more efficient, could you please explain a bit more...

Edited by christianchoice

Share this post


Link to post
Share on other sites
but i need to be able to control the speed of the flips. I need to be able to pause on a page, then go to the next one, etc.

 

I didn't say anything else. ;-) Consider: What's stopping you from massaging time as you see fit? Nothing! Just like you would slow down the notorious wiggle() by rigging it with sliders, you could add an extra multiplier for time... On the abstract level you'd have to do the following:

 

- determine the current "segment" by dividing the overall time based on the prototype animation duration (Math.floor(time/(keyB-keyA))

- match the result to the index to determine animation order

- compare the time within a segment to the reference animation and use it to drive the animation (valueAtTime(time - index*(keyB-keyA))

- add a multiplier to the time to control flipping speed based on a expression slider (valueAtTime(time *speedSlider - index*(keyB-keyA))

 

From there you can refine it infinitely. The slider can either be "global" (covering the full time of all layers) or "local" (for the current segment). The first is simpler of course, the second provides finer control. For the latter you would use a modulus division (%) to reset the slider as the animation changes segments. The downside is that time() can never be zero, so it will technically never fully freeze. This could be circumvented by nesting the comp and using time-remapping on the uniformly animated expression stuff. You could also use the layer's inPoint() and work with the Sequence Layers keyframe assistant to determine animation order. Quite a few options...

 

Mylenium

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...