ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

if/else - position

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michał Chraper
if/else - position
on Mar 27, 2018 at 8:56:16 am

Hi,

I'm trying to write expression that moves object as long as "speed" parameter is not equal to 0. I have no alert from AE about that code but it doesn't do the job, nothing happens...

speed = effect("Slider Control")("Slider");
x = transform.position[0];
y = transform.position[1];

if (speed == 0) {[x, y]}
else {[x + time*speed, y]}


Return to posts index

Dan Ebberts
Re: if/else - position
on Mar 27, 2018 at 4:31:53 pm

Animating speed in AE is not simple. This may be helpful:

http://www.motionscript.com/articles/speed-control.html


Dan



Return to posts index

Michał Chraper
Re: if/else - position
on Mar 28, 2018 at 9:31:02 am

Thanks for respond Dan. Reading the article You quoted I understood where is the problem in my expression. I didn't know that I can't use "speed" word as variable name. Since I change it to "spd" shortcut expression started to work.

Indeed it's a bit complicated to control acceleration and deceleration but until you want to control constant speed, e.g. by slider control, it's easy as my expression ;)


Return to posts index


Michał Chraper
Re: if/else - position
on Mar 28, 2018 at 9:36:05 am

So, with little modification, working code looks like that...

spd = effect("speed")("Slider");
x = value[0];
y = value[1];

if (spd == 0) {[x, y]}
else {[x + time*spd, y]}


Return to posts index

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