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

How to alternate between two states using expressions

Explorer ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

//Alternate between two states for any given duration respective of the inputs. This requires two inputs; preferably slider controllers, called "Time A" and "Time B" on a layer called "Control".

 

t = time;
a = thisComp.layer("Control").effect("Time A")("Slider");
b = thisComp.layer("Control").effect("Time B")("Slider");
y = b/a + 1; //fancy math so the slider numbers match the time in seconds.
z = a * y;

if(t % z < a)
"state 1";
else
"state 2";

TOPICS
Expressions , How to

Views

90

Translate

Translate

Report

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
LEGEND ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

And what exactly is the problem? What are your "states" supposed to be?

 

Mylenium

Votes

Translate

Translate

Report

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
Explorer ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

LATEST

I just discovered how to alternate between two states using expressions and I wanted to share. But my math is overly complicated (a result of initially not caring how long the second state lasted). It should be:

 

t = time;
a = thisComp.layer("Control").effect("Time A")("Slider");
b = thisComp.layer("Control").effect("Time B")("Slider");
x = a + b;

if(t % x < a)
"state 1";
else
"state 2";

 

Seems super obvious now that's it's done... ¯\_(ツ)_/¯

Votes

Translate

Translate

Report

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