ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Issues with if/else command.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Jouppi
Issues with if/else command.
on Dec 7, 2016 at 9:42:42 pm
Last Edited By David Jouppi on Dec 7, 2016 at 10:21:23 pm

Hey there!

Im running into a problem with an "if else" command. I have around 100 objects in a comp that I'm trying to assign a random rotation speeds to. I want them to either rotate to the left or the right. Additionally, regardless of which direction they're rotating, I want them to stay within a speed range, so that I can avoid having any of them standing totally still, or moving wayyyy to fast. I wrote out the following experession, which I figured should work, however, they always end up rotating in the same direction. Anyone know whats going on? I deduced the problem is happening at the the 3rd line. I cant get variable "drctn," to result in anything besides the value: -1. I assume I'm using the "if else" command incorrectly.

rndmA = Math.round(random(1,2));
if ( rndmA = 1 ) [drctn=-1] else [drctn=1];
animSpd = random(20,60);
time * (animSpd*drctn)

Return to posts index

Dan Ebberts
Re: Issues with if/else command.
on Dec 7, 2016 at 10:27:27 pm

I think you just need to change:

( rndmA = 1 )


( rndmA == 1 )


Return to posts index

David Jouppi
Re: Issues with if/else command.
on Dec 7, 2016 at 10:38:06 pm

That worked! Thanks so much, Dan! I don't know what everyone would do without your expertise!

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved