Highlighted

Fire action on every keyframe

Explorer ,
May 03, 2019

Copy link to clipboard

Copied

I want drive change of effect property on every keyframe: it would change its value from 0 to 1 and vice versa (basically on & off).

So far I have this expression for the effect "Dust & Scratches" sitting on its "Threshold" property:

var v = 1;

var n = timeRemap.numKeys;

if (n > 0){

    if(time < timeRemap.nearestKey(time).time){

        if(v == 0){

            v = 1;

        }else{

            v = 0

        }

    }

}

v

Problem is I would like to be able fire the change exactly on every new keyframe but I am not able to get there, this is the closest but of course it changes the value "erratically" once it reaches middle point between two frames.

I tried also this but to no success too as the variables kfA/kfB are initialized with every frame 😞

var kfA = 1;

var kfB = 2;

var v = 1;

var n = timeRemap.numKeys;

if (n > 0){

    if(time >= timeRemap.key(kfA).time && time < timeRemap.key(kfB).time){

        if(v == 0){

            v = 1;

        }else{

            v = 0

        }

    }

    if(time == timeRemap.key(kfB).time){

        kfA++;

        kfB++;

    }

}

v

I posted this in your other thread but as suggested, posting it here too. Apply it to the Threshold property of the Dust & Scratches effect.

Glad to hear it works!

a = timeRemap;

nearestKey = a.nearestKey(time).index;

if (time < a.key(nearestKey).time) nearestKey --;

if (nearestKey/2 != Math.round(nearestKey/2)) 0;

else 255;

Translation for the above would be:

grab the timeRemap property for this layer

find the index of the nearest remap keyframe at the current time (expressions are recalculated on each individual frame)

if the current time is earlier than the nearest keyframe, reduce 'nearestKey' by 1 so we're always considering the keyframe before the current time.

if keyframe is an odd value (i.e. if value divided by 2 doesn't equal the same result rounded down) make the value 0, otherwise make it 255.

TOPICS
Expressions

Views

305

Likes

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

Fire action on every keyframe

Explorer ,
May 03, 2019

Copy link to clipboard

Copied

I want drive change of effect property on every keyframe: it would change its value from 0 to 1 and vice versa (basically on & off).

So far I have this expression for the effect "Dust & Scratches" sitting on its "Threshold" property:

var v = 1;

var n = timeRemap.numKeys;

if (n > 0){

    if(time < timeRemap.nearestKey(time).time){

        if(v == 0){

            v = 1;

        }else{

            v = 0

        }

    }

}

v

Problem is I would like to be able fire the change exactly on every new keyframe but I am not able to get there, this is the closest but of course it changes the value "erratically" once it reaches middle point between two frames.

I tried also this but to no success too as the variables kfA/kfB are initialized with every frame 😞

var kfA = 1;

var kfB = 2;

var v = 1;

var n = timeRemap.numKeys;

if (n > 0){

    if(time >= timeRemap.key(kfA).time && time < timeRemap.key(kfB).time){

        if(v == 0){

            v = 1;

        }else{

            v = 0

        }

    }

    if(time == timeRemap.key(kfB).time){

        kfA++;

        kfB++;

    }

}

v

I posted this in your other thread but as suggested, posting it here too. Apply it to the Threshold property of the Dust & Scratches effect.

Glad to hear it works!

a = timeRemap;

nearestKey = a.nearestKey(time).index;

if (time < a.key(nearestKey).time) nearestKey --;

if (nearestKey/2 != Math.round(nearestKey/2)) 0;

else 255;

Translation for the above would be:

grab the timeRemap property for this layer

find the index of the nearest remap keyframe at the current time (expressions are recalculated on each individual frame)

if the current time is earlier than the nearest keyframe, reduce 'nearestKey' by 1 so we're always considering the keyframe before the current time.

if keyframe is an odd value (i.e. if value divided by 2 doesn't equal the same result rounded down) make the value 0, otherwise make it 255.

TOPICS
Expressions

Views

306

Likes

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
May 03, 2019 0
Engaged ,
May 03, 2019

Copy link to clipboard

Copied

I posted this in your other thread but as suggested, posting it here too. Apply it to the Threshold property of the Dust & Scratches effect.

Glad to hear it works!

a = timeRemap;

nearestKey = a.nearestKey(time).index;

if (time < a.key(nearestKey).time) nearestKey --;

if (nearestKey/2 != Math.round(nearestKey/2)) 0;

else 255;

Translation for the above would be:

grab the timeRemap property for this layer

find the index of the nearest remap keyframe at the current time (expressions are recalculated on each individual frame)

if the current time is earlier than the nearest keyframe, reduce 'nearestKey' by 1 so we're always considering the keyframe before the current time.

if keyframe is an odd value (i.e. if value divided by 2 doesn't equal the same result rounded down) make the value 0, otherwise make it 255.

Likes

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
Reply
Loading...
May 03, 2019 1
Explorer ,
May 03, 2019

Copy link to clipboard

Copied

Thank you once again!

Likes

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
Reply
Loading...
May 03, 2019 0