Forum Replies Created

Page 27 of 32
  • Xavier Gomez

    May 30, 2013 at 2:34 pm in reply to: non circular spiral

    This works for any polygone. It can be simplified though if you need a regular shape, and it is probably easier to animate the “angle” and the “radius” with aditionnal sliders than to use functions (caps are to see them for afar…)

    ///////////////////////////////// TWEAKS ///////////////////////////////////////
    function ANGLE(t){ // returns an angle in degrees...
    return t * 60;}

    function RADIUS(angle){ // angle is in radians ...
    return angle * 10;}

    center = [thisComp.width*0.5, thisComp.height*0.5];
    angleList = [0,30, 120,150, 240,270] // degrees, in increasing order, from 0 (included) to 360 (excluded)

    /////////////////////////////////////////////////////////////////////////////////////

    last = angleList.length-1;

    a=ANGLE(time); // use a function as above, or a slider to animate the angle (same for the radius)
    n=Math.floor(a/360);
    b=a-n*360;

    if (b<=angleList[0]){ // < === "less or equal"
    a1 = (n-1) * 360 +angleList[last]; a2 = n*360+angleList[0];
    }
    else if (angleList[last]<=b){
    a1 = n * 360 + angleList[last]; a2 = (n+1)*360+angleList[0];
    }
    else{
    idx=0;
    while (b>angleList[idx+1]){idx++;};
    a1 = n * 360 + angleList[idx++]; a2 = n*360+angleList[idx];
    }

    a = degreesToRadians(a);
    a1 = degreesToRadians(a1);
    a2 = degreesToRadians(a2);
    P = RADIUS(a1) * [Math.cos(a1), Math.sin(a1)];
    Q = RADIUS(a2) * [Math.cos(a2), Math.sin(a2)];

    center + linear(a, a1, a2, P,Q)
    ;

  • There is a smooth expression, it is:
    smooth(width = 5*thisComp.frameDuration, samples = 5, t = time + 2*thisComp.frameDuration);

    You can use this expression in the audio amplitude (“Both Channels”).

    ==> link (towards the bottom of the page).
    I’m not sure what the parameter t exactly is, probably the center of the sampling interval. In that case, if you want to sample over the next 5 frames, use the expression above. But if you want to take into account values before and after the current time, just leave the default (t=time) or omit it. Then the expression takes “samples” samples over a width of “width” seconds around t and returns the average, but i’m also not sure if it is a weighted average or flat.

    You might be disappointed by what it does though. The smooth expression is fine, but maybe not what you are after for your animation.

  • An alternative, built upon Dan Ebberts’ expression:

    holdTime = 0.5;
    n = 4;
    t0 = inPoint;
    t = time-t0;
    STEPS = 1 + Math.floor(t/holdTime);

    // initially generate a number in {0,1,..., n-1}
    seedRandom(0,true);
    idx = Math.floor(random(n));

    // if (t>= holdTime)add something non zero, step after step
    for(var step=1; step< STEPS; step++){
    seedRandom(step, true);
    idx = (idx + Math.floor(random(n-1)+1)) % n;}

    //return
    idx + 1;

  • Xavier Gomez

    May 12, 2013 at 8:14 am in reply to: Layer Movements Transformers Logo effect

    Someone has uploaded templates that reproduce this kind of animation:
    https://www.youtube.com/watch?v=JcM8Fo58nHQ
    (His templates are on CS6 Windows).

  • Xavier Gomez

    April 30, 2013 at 1:16 pm in reply to: wiggle within a cirlcles radius – how?

    You can try this:
    f = 0.7;
    R = 300;

    w = wiggle(f,R,2) - value;
    z = Math.max(Math.abs(w[0]), Math.abs(w[1]));
    w = z*normalize(w);
    value + w;

    If it is very important that the position stays in the specified disc, you may have to reduce the radius a bit, especially if you add harmonics to the wiggle.

    You can also try polar coordinates. Put 2 controls:
    Slider: name: “radius”, value: 150, expression: wiggle(0.7,150,2);
    Angle: name: “angle”, value: any, expression: wiggle(0.1,720,2);

    and this expression on the position:
    radius = effect("radius")("Slider");
    angle = effect("angle")("Angle")*Math.PI/360;
    value + radius*[Math.cos(angle),Math.sin(angle)];

    Changing the wiggle parameters for the radius and the angle give completely different behaviours (it is better to add harmonics to the angle than higher frequency, otherwise the solid moves in too obvious circles).

  • Xavier Gomez

    April 19, 2013 at 5:44 pm in reply to: Horse Race Game

    if you want the horses to stand still for a couple of seconds before the start of the race, set kickTime = 2 (assuming that your comp start time is 0). This is only useful if you use the second method i give you to get the “Master speed”. If you animate by hand the “MASTER” HORSE you dont need this.

    For the remaining of the question i dont understand. I thought it was a random race with random results…

    Also the last lines of the last expresion i gave you should be replaced by
    for (var f = 0; f<=numFrames; f++){
    x += vel.valueAtTime(t);
    t += dt; }
    value - x*dt*[1,0];

    It does the same, but should be significantly faster.

  • Xavier Gomez

    April 19, 2013 at 12:03 pm in reply to: Offset range expression

    Between the offset and slide lines add this:
    seedRandom(index,true)

    It takes a different random number for each layer, but doesnt take a new random number at every frame.

  • Xavier Gomez

    April 19, 2013 at 11:52 am in reply to: Using variables to build an expression in a script

    layerArray[3] is a layer object, you only want a string that refers to it. I’m not sure for the sequel though.

    To refer by index, maybe “thisComp.layer(” + layerArray[3].index + “)” + “.transform.position;”;

    Similarly for reference by name.

  • Xavier Gomez

    April 19, 2013 at 11:44 am in reply to: Horse Race Game

    I can help for one aspect (horse not moving backwards!) but some other aspects of your project are kinda more difficult:
    – to reproduce realistic behaviour of a horse is hard with a simple wiggle.
    – also to obtain different race results in the same settings require some knowledge in seedRandom which i havent…

    For what i can help,you can procede this way:
    1) Create an ideal horse (without wiggle) that will give the generic behaviour of your horses.
    Just create a Null Object (rename it MASTER HORSE), and animate it smoothly from start to end (with 2 or more keyframes).
    Adjust temporal tangents so that it starts with 0 speed and ends at max speed.
    On that null, apply a slider control (Effects > Options for Expressions > Slider Control), rename it master speed), alt+Click the stopwatch to activate the expression field and enter this expression:

    position.speed

    Instead of animating the null and taking its speed, you can also directly enter an explicit expression for the Master Speed slider:

    maxSpeed = 75;
    t0 = 2; // kick time
    T = 2;

    t = time - t0;
    (t<0) ? 0 : maxSpeed * (1 - Math.exp(-t/T))

    2) Take one horse layer, add a slider control, name it Horse Speed, and use this expression:
    f = 1; // wiggle frequency
    w = 10; // wiggle amount
    t0 = 2; //kicktime

    if (time < t0) 0 else{
    x = wiggle(f,w) + thisComp.layer("MASTER HORSE").effect("master speed")("Slider");
    (x > 0) ? x : 0;
    }

    This gives each horse its individual speed. Sort of naive though and it is the part that should be improved.

    3) Then for the position property of the horse, set the value to the start position and don’t animate it (with keyframes). For the expression, enter this:

    x = 0;
    vel = effect("Horse Speed")("Slider");
    dt = thisComp.frameDuration;
    t=- dt;
    numFrames = timeToFrames(time);

    for (var f = 0; f<=numFrames; f++){
    x += vel.valueAtTime(t)*dt;
    t += dt;
    }

    value - x*[1,0];

  • Xavier Gomez

    April 18, 2013 at 5:56 pm in reply to: Horse Race Game

    you can use wiggle, but on the speed, not the position itself, then integrate the speed. To get more precise, you should tell if your problem is 1D (horses moving in straight lines) or 2D (horses running in “circles”). It’s not quite the same since for 2D closed path you will want to wiggle only in one direction (tangent to the movement).

Page 27 of 32

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