Forum Replies Created

  • Sam Beckett

    November 24, 2020 at 7:06 am in reply to: Move a layer according to its own location

    Thank you Dan.

    I tried to add two slider controls that get the value of position. Then I tried to real these values.

    I have 3 layers but only one has expressions.

    Slider Control X :

    Initialized to 1 (blue value)

    transform.position[0]


    Slider Control Y :

    Initialized to 1

    transform.position[1]


    Layer Position :

    Initialized to [1000,500]

    seedRandom(0, timeless = true) ;
    X_Pos = effect(“X“)(“Control“) ;
    Y_Pos = effect(“Y“)(“Control“) ;

    But it behaves the same. The layer doesn’t move frame by frame.

    _______________________________________________________

    As you suggest, I will have to calculate all the positions of every frames of every layers till the current time.

    Each frame, the expression will recalculate all these and place the current layer according to time.

    ?To achieve this I will need to store all these informations into a 3 dimentional array (not a 3 cells array like a 3D position). I know this exists in C/C++ but does it in javascript ?

  • Sam Beckett

    November 23, 2020 at 11:56 pm in reply to: Move a layer according to its own location

    Thanks a lot for your reply Dan.

    I don’t expect any problem because each layer at a time makes a move (of any defined value) then the next frame launches the process again.

    But without considering this, let’s imagine the comp has only one layer. How would you move it according to its current location ?

    Here is a random example :

    During this frame :
    if its “x” value is odd, then add one to its “y” value
    else, then substract one to its “y” value
    if its “y” value is a multiple of 3, then add 1 to its “x” value
    else, then substract one to its “x” value
    [x,y]

    And next frame, the script restatrs its routine and the layer moves in a certain way.

  • Sam Beckett

    February 23, 2017 at 1:31 pm in reply to: Variable frequency for a sinusoidal movement

    Thank you very much, this may be very helpful to sort this out very easily.
    With all these responds I might close this thread as answered.

    Thank you all for your help.

  • Sam Beckett

    September 19, 2016 at 10:18 pm in reply to: Variable frequency for a sinusoidal movement

    Understood, thanks a lot for your so quick help.

    Now I am sorry but if I follow the document there isn’t any solution given for my precise case :
    Controlling the frequency with a wiggle expression.

    So I try to follow the principle with the following code :

    Freq_Min = 1 ;
    Freq_Max = 2 ;
    Freq_Offset = Freq_Min ;
    Freq_Delta = (Freq_Max - Freq_Min) / 2 ;

    freq = Freq_Offset + wiggle(0.1, Freq_Delta) + Freq_Delta ;
    amp = 100;
    n = freq.numKeys;
    if (n > 0 && freq.key(1).time < time){
    accum = freq.key(1).value*(freq.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (freq.key(i).time > time) break;
    k1 = freq.key(i-1);
    k2 = freq.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
    }else{
    accum = freq.value*(time - inPoint);
    }
    value + amp*Math.sin(accum*Math.PI*2)

    But the expression returns an error.
    As the wiggle into the “freq” variable breaks the rest of the code, I put the frequency wiggled into a Slider Control :
    Frequency Slider :
    Freq_Min = 1 ;
    Freq_Max = 2 ;

    Freq_Offset = Freq_Min ;
    Freq_Delta = (Freq_Max - Freq_Min) / 2 ;

    Freq_Offset + wiggle(0.1, Freq_Delta) + Freq_Delta ;

    Y Rotation parameter :
    freq = thisComp.layer("Prarmètres généraux").effect("Frequency")("Slider") ;

    amp = 100;
    n = freq.numKeys;
    if (n > 0 && freq.key(1).time < time){
    accum = freq.key(1).value*(freq.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (freq.key(i).time > time) break;
    k1 = freq.key(i-1);
    k2 = freq.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
    }else{
    accum = freq.value*(time - inPoint);
    }
    value + amp*Math.sin(accum*Math.PI*2)

    Now the program doesn’t contain any error but the graph behaves wrongly.
    So It turns that we have to work with an integrator expression, like your document explained but in my case we control the frequency of the sinwave by a wiggle expression. That is where I’m stuck.

  • Sam Beckett

    September 19, 2016 at 8:45 pm in reply to: Variable frequency for a sinusoidal movement

    Thanks a lot Dan, this si exactly what I needed.
    You couldn’t give me a better analysis.

    Do you have any clue why my initial wiggle that shouldn’t overpass the [9;10] interval does it anyway ? It looks like there is a kind of 10% overpassing but I don’t know why.

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