Forum Replies Created

Page 4 of 6
  • David Conklin

    December 4, 2014 at 12:19 am in reply to: Cogs with Bar attached always oriented in one axis

    This solution is a bit more complicated.

    You essentially need to get the ‘global’ position of your gear null, not the position it’s inherited from it’s parent. You can use an expression like this to link your bar’s position to the global position of the Gear null.

    p = thisComp.layer("Gear");
    p.toComp(thisComp.layer("Gear").transform.anchorPoint)

    Once you’ve established that link, you just need to do the same thing to your rotation expression:

    var gear = thisComp.layer("Gear");
    var hole = thisComp.layer("Hole");

    var dist = hole.transform.position - gear.toWorld(gear.transform.anchorPoint);

    radiansToDegrees(Math.atan(dist[1]/dist[0]));

    Have a look at this file to help clear things up.
    8262_gearbarholeworldtransform.aep.zip

    Good luck!

    David Conklin
    Motion Designer

  • David Conklin

    December 3, 2014 at 11:32 pm in reply to: Cogs with Bar attached always oriented in one axis

    Assuming you have 2 nulls at either end of your bar.. the left being called “Gear” and the right being called “Hole.” This also assumes that the anchor point of your bar is at 0 on the X-axis (i.e. all the way at the left). The position of your bar should be linked to the position of the “Gear” null.

    Put this on the rotation prop:

    (or, check out this file):
    8261_gearbarhole.aep.zip

    //expression for rotation prop.

    //get layers
    var gear = thisComp.layer("Gear");
    var hole = thisComp.layer("Hole");

    //get 2 sides of triangle
    var dist = hole.transform.position - gear.transform.position;

    //do math
    radiansToDegrees(Math.atan(dist[1]/dist[0]));

    David Conklin
    Motion Designer

  • David Conklin

    December 3, 2014 at 10:42 pm in reply to: Make wiggle random across compositions?

    The seed random is your best bet, but using index as an input isn’t going to help you if all your layers are the same index (i.e. if they’re all the 3rd layer in their respective comps). Additionally, the second argument to the seedRandom() function does not apply to wiggles.

    You will need to feed the seedRandom() function a value which will be unique for every layer in every comp. It’s hard to say without knowing your exact setup, but if you have numbered comps, for instance

    RENDERCOMP_1
    RENDERCOMP_2
    RENDERCOMP_3

    You could use the integer attached to the name by doing something like

    thisComp.name.match(/\d+$/gi);

    to extract the # from the name. I have also had success by counting the # of characters in layer names, total number of layers, etc. You just have to find something that is different about Comp A from Comp B and use that as your seed.. this is a pain in the rear if your comps are designed to be as identical as possible for versioning purposes.

    There has to be a better way to do this. Maybe someone else can chime in.

    David Conklin
    Motion Designer

  • David Conklin

    December 2, 2014 at 7:49 pm in reply to: Opacity Wiggle Checkbox Control

    Yes, for some reason the code here formatted the less than sign improperly. You can just fix that on line 17 and it works fine.

    If you are looking for a ‘slower’ random, your best best would be to explore the ‘noise’ function, rather than random. Random, and gaussRandom, are going to be calculated each frame – there’s no way to make them generate less often other than defining which frames they should be active on, as we did above.

    The noise() function, on the other hand, takes a custom input and the differences in the output correlate to the differences in the inputs. For example:

    noise(1) is much closer to noise(1.1) than noise(100).

    Using this, you can create much more similar values from the noise function by feeding it values that are very close to one another. For instance:

    noise(time / 10) or noise(time/100000)

    Keep in mind, though, that while this will have longer periods of ‘off’, it will also have longer periods of ‘on,’ so I’d suggest combining this with some of what we did above to keep your ‘blinks’ short.

    Good luck.

    David Conklin
    Motion Designer

  • David Conklin

    December 2, 2014 at 6:14 pm in reply to: Stop expressions expression?

    As far as I am aware, you cannot access the time of another comp – only the time in the comp in which the expression is written. However, if you make a new null inside your master, call it ‘timecount’, place a slider on it, name the slider ‘timecount’ and add this expression onto that slider

    time;

    You now have a marker of the current time in your master comp.

    Now, you just need to wrap all of your expressions inside your precomp in an if-else statement. There are lots of nice tools to do this, pt_ExpressEdit is one of my favorites. You can do it manually, of course, if you don’t have too many.


    var theTime = comp("masterComp").layer("timecount").effect("timecount")("Slider");
    var timeToStopExp = 10; //seconds
    if(time < timeToStopExp){
    //place your expression here.
    ] else {
    //the disabled value here:
    value;
    }

    Change the timeToStopExp variable to whatever second you want your expressions to be turned off.

    Good luck!

    David Conklin
    Motion Designer

  • David Conklin

    December 2, 2014 at 6:07 pm in reply to: Skipping marker to adjust opacity

    The expression attached below will give you the time of the 2nd marker ahead of your playhead.

    var action = thisComp.layer(1);

    //get the time of the closest key.
    var theKey = action.marker.nearestKey(time);

    //determine if nearest key is before or after
    //the current time
    var lookAhead;

    if(theKey.time <= time){
    //key is before, get 2 markers past this one.
    lookAhead = Math.min(theKey.index + 2, action.marker.numKeys);
    } else {
    //next key is ahead, get one marker past this one.
    lookAhead = Math.min(theKey.index + 1, action.marker.numKeys);
    }

    //get time of 2 keys ahead.
    var twoKeysAheadTime = action.marker.key(lookAhead).time;

    twoKeysAheadTime;

    However, this will not be useful to you in constructing a fade as the way the linear() function works cannot create values in the future. Take this as an example:

    linear(time, nextMarker.time, twoMarkersahead.time, 0, 100);

    This expression won’t do anything as your playhead (i.e. the value of time) can, by definition, never be between the next marker and 2 markers ahead, it will either be 1) before all markers, 2) between the previous and next marker, or 3) past all markers.

    So, let’s discuss other ways of doing this. If you know that you want your fade to happen between the last 2 markers on your layer, you could do something like:

    linear(time, marker.key(marker.numKeys-1).time, marker.key(marker.numKeys).time, 0, 100);

    You can change the numbers to move back to the third-to-last and second-to-last keyframes as such:

    linear(time, marker.key(marker.numKeys – 2).time, marker.key(marker.numKeys – 1).time, 0, 100);

    Hopefully that points you in the right direction. If you have more info about what, exactly, it is you’re trying to do I may be able to give you some case-specific advice.

    Good luck!

    David Conklin
    Motion Designer

  • David Conklin

    December 2, 2014 at 3:24 pm in reply to: Opacity Wiggle Checkbox Control

    You could impose some sort of frame checker to space out these ‘blinks’ in the code below, I use the modulo operator, which essentially does division and returns the remainder, meaning 10%3 = 1, since 3 goes into 10 evenly 3 times with 1 left over.

    Using this you can tell the expression to only have a chance to be turned on when a frame is a multiple of a specific number. For example, if you enter ’25’ into the check frame var, the random expression will only work on frames 25, 50, 75, 100, 125…. if you changed it to 33 it would only work on 33, 66, 99, 132, etc.

    The random expression is the same here.

    The gist of this expression is that every 25th frame has an 20% chance of being on. Increasing the checkFrame variable gives less frames the chance to be turned on, increasing the prob variable will increase the chance that each checked frame will be on.

    Give this a go and let me know.

    //get the frame number.
    var frameNum = time/thisComp.frameDuration;

    //remove decimals for not-even frame
    //rates like 29.97
    frameNum = frameNum.toFixed(0);

    //number to check against. If frame number is
    //divisible by this number, it has a chance
    //to be turned on.
    var checkFrame = 25;

    //probability that that the random check
    //will pass (% on)
    var prob = .2;

    //if we're on a frame which is a multiple
    //of check frame (25, 50, 75, 100, 125...)
    if(frameNum%checkFrame == 0){
    //have an 20% chance to be on.
    (gaussRandom() &lt; prob) ? 100 : 0;
    } else {
    //not on a checked frame, off.
    0;
    }

    David Conklin
    Motion Designer

  • David Conklin

    December 1, 2014 at 11:59 pm in reply to: Opacity Wiggle Checkbox Control

    Using the random() function you can generate a normalized value between 0 and 1. You can then check this random number against a number you set. For instance:


    var r = random();
    var percentage = .8;
    if(r > percentage) {
    1;
    } else {
    0;
    }

    In the above example, picking .8 means that anything under .8 will turn the checkbox off, anything above will turn it on. Since the likelihood of getting a number between 0-1 less than .8 is 80%, you can control how frequently each state occurs. If you want it to be off 20% of the time you could change the percentage to .2, if you wanted it off 50% if the time you could use .5.

    If you want smoother random numbers, try using a gaussian random instead of the regular random.

    Good luck!

    David Conklin
    Motion Designer

  • David Conklin

    December 1, 2014 at 11:54 pm in reply to: Skipping marker to adjust opacity

    It is hard to say without knowing what exactly you mean by ‘a few’ keyframes and which marker you’d like to skip. Perhaps some more info could be helpful in determining a solution for you.

    That being said, it seems that what you’re looking for is highly case-specific. Perhaps instead of trying to code everything using one set of markers/keys, you can make another layer called ‘transition_markers’ with only the markers relevant to your fades or something and point your expression to that layer.

    Give some more info and I’ll do my best to help you. 🙂

    David Conklin
    Motion Designer

  • Hey Josey.

    My apologies for not getting back to you sooner, I was away from the computer for the long weekend.

    I think you’re getting confused about how to use the expression. position[#] does not refer to an explicit position value, but instead one property of the position vector. I’m attaching a file to show you how to use this expression properly. Essentially, you have a layer that’s 3D and this expression reads its X, Y and Z values, multiplies them by a scaler number, and then formats those values to use on a single text layer’s source text property

    8251_satellitetrack.aep.zip

    Hopefully this is helpful to you.

    Good luck!

    David Conklin
    Motion Designer

Page 4 of 6

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy