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

Check on(√) and Hold(?) every X frames?

Community Beginner ,
Sep 15, 2018 Sep 15, 2018

Copy link to clipboard

Copied

Hey everyone,

I have done a lot of searching and trying out, but still can not seem to figure out how to get this to work (while using only one layer).

Simply said: I want to create an expression for a Checkbox Control that allows me to check it on every 24th frame and hold it for 2 frames (before it goes off again).

To check it on every 24th frame was not that hard, but to hold it for 2 extra frames just does not seem to work for me.

Code (to turn it on every 24th frame):

frameCount = timeToFrames(time);

if (frameCount%24 == 0) {

  value == 1

} else {

  value == 0

}

Any help is appreciated!

Yoshi

TOPICS
Expressions

Views

304

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

correct answers 1 Correct answer

Community Expert , Sep 15, 2018 Sep 15, 2018

Since the frame count starts at 0, the 24th frame would be frame 23. So it would be on at frames 23,24,47,48, etc. I think this does that:

f = timeToFrames(time);

(f%24 == 23) || ((Math.floor(f/24) > 0) && (f%24 == 0))

If that's not exactly what you wanted, it should be easy to adjust...

Dan

Votes

Translate

Translate
Community Expert ,
Sep 15, 2018 Sep 15, 2018

Copy link to clipboard

Copied

Since the frame count starts at 0, the 24th frame would be frame 23. So it would be on at frames 23,24,47,48, etc. I think this does that:

f = timeToFrames(time);

(f%24 == 23) || ((Math.floor(f/24) > 0) && (f%24 == 0))

If that's not exactly what you wanted, it should be easy to adjust...

Dan

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
Community Beginner ,
Sep 15, 2018 Sep 15, 2018

Copy link to clipboard

Copied

LATEST

Dan,

I appreciate the quick answer. It was exactly what I was looking for.

I was staring myself blind on finding a way to fix this within the if-statement (with delays, time offsets, etc.). This seems so logical, but still I could not figure it out haha. And you are right, I meant the 23th frames instead of the 24th (keep forgetting counting the 0 frame).

Thank you so much!

Yoshi

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