ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

If statement doesn't work in expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Viktor Synkov
If statement doesn't work in expression
on Mar 23, 2017 at 4:26:06 pm

I'm trying to make clouds move out of frame and than appear again from the other side.



First time if statement works as expected. tBound becomes 40s and it offsets cloud. But when time gets bigger than 40 nothing happens. Neither offset variable gets bigger nor tBound. If statement doesn't work anymore. What's the problem here?

var vel = 100;
var pInit = position.valueAtTime(0)[0]; // initial position of a cloud
var tInit = (thisComp.width-pInit)/vel; // time it takes to cross the right border starting from init position
var tFull = (thisComp.width+width)/vel; // time it takes to cross the frame starting behind the left border
var offset = 0;
tBound = tInit;

if(time > tBound) {
tBound += tFull;
offset += thisComp.width+width;
}

[value[0]+time*vel-offset,value[1]]


Return to posts index

Dan Ebberts
Re: If statement doesn't work in expression
on Mar 23, 2017 at 6:48:14 pm

It looks like you may be assuming an expression will remember values from previous frames. It won't. What is it you're trying to do?

Dan



Return to posts index

Lars Jandel
Re: If statement doesn't work in expression
on Mar 23, 2017 at 8:14:53 pm

Couldn't you use just the "Motion Tile" animation preset and animate the tile center's x-axis? You could easily put an expression on that property and change the speed.
Just an idea for a simple solution… đŸ˜‰

Cheers, Lars.

x = time*100;
y = effect("Motion Tile")("Tile Center")[1];
[x, y]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]