Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Move in x every [10] frames?

Participant ,
Dec 20, 2016 Dec 20, 2016

Hi!

Trying to figure out how out how to script this:

• Move an object forward in x every [45] frames the whole time of the comp. And no movement at all.


I tried doing this setup:

----------

length = Math.floor(thisComp.duration);

lengthFrames= timeToFrames(length);

cycle = lengthFrames/thisComp.layer("Null 2").effect("Value")("Slider");

tid = Math.floor(timeToFrames(time));

if (tid % cycle == 0) {

transform.xPosition +10;

}

----------

(I used a null layer with a slider for easier debugging and so I can change the value on the fly later.)
The equation results in 0 every 45th frame – which is good but the movement happens every frame. I can't figure out how to trigger a certain movement just on that occasion and nothing else!

Somebody in here that has a suggestion how to solve this?

Best

TOPICS
Expressions
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 20, 2016 Dec 20, 2016
LATEST

Maybe this works:

tStart = inPoint;

period = thisComp.layer("Null 2").effect("Value")("Slider").value;    // assumed: frames

DX = 10;    // pixels

period *= thisComp.frameDuration;

t = time-tStart;

if (t<=0){value;}else{

    nStep = Math.floor(t/period);

    value + nStep * DX;

    };

It is assumed that dimensions are separated (because it looks to be so from your expression).

If not, you should replace: value + nStep * DX;

by: [value[0] + nStep * DX, value[1]];

And the slider is assumed to give the time period in frame units.

If seconds, comment out the line period *= thisComp.frameDuration;

Xavier

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines