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

Help with modifying Dan Ebberts' code

New Here ,
Oct 17, 2018 Oct 17, 2018

Copy link to clipboard

Copied

Heya,

I will try my best to explain the issue I'm having.

I've been using Dan Ebberts' "Triggering Animation With Markers" expression code for quite a while now and it worked perfectly until recently, here's what happened:

I used the code on a pre-comp and animated it's layers, I triggered it in the main comp with markers and it worked perfectly.

Then I made a "controller" layer for that pre-comp in the main comp with multiple checkbox controls on it. I tied the opacity of the layers within the pre-comp that the expression is applied to onto the checkbox controls, there are 3 layers in total in the pre-comp, each checkbox is tied to the opacity of one or multiple of those layers and I am using this to hide/reveal different layers at different times to swap between the animated character's gestures in a single frame. Now this is where the problem arrises...

What ends up happening is, the checkbox control keyframes hide their linked layers inside of the pre-comp at the correct times without any issues but when it comes to the main comp, the opacity either refuses to change or is very heavily delayed from where the checkbox controls' keyframes are, depending on where I've placed the markers in the main comp.

So my question is, is there a way to get around this or somehow modify Dan's code so that it completely ignores the opacity transform property of the layers inside the pre-comp it's applied to and allows me to animate their opacity at the exact points where the checkbox control keyframes are, regardless of where the animation markers are for the rest of the transform properties without any interruption or delay?

For reference, this is Dan's code that I am using:

action = comp("COMPNAME").layer("action");

n = 0;

if (marker.numKeys > 0){

  n = marker.nearestKey(time).index;

  if (marker.key(n).time > time){

    n--;

  }

}

if (n == 0){

  0

}else{

  m = marker.key(n);

  myComment = m.comment;

  t = time - m.time;

  try{

    actMarker = action.marker.key(myComment);

    if (action.marker.numKeys > actMarker.index){

      tMax = action.marker.key(actMarker.index + 1).time - actMarker.time;

    }else{

      tMax = action.outPoint - actMarker.time;

    }

    t = Math.min(t, tMax);

    actMarker.time + t;

  }catch (err){

    0

  }

}

And this is the code I am applying on the pre-comp layer's opacities:

if(comp("COMPNAME").layer("LAYERNAME").effect("EFFECTNAME")("Checkbox") ==1) 100 else 0;

Let me know if you need any other information.

Thanks in advance!

TOPICS
Expressions

Views

1.1K

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 , Oct 18, 2018 Oct 18, 2018

Yeah, the opacity changes would have to be baked into the actions. Think of the precomp as a pre-rendered movie--all my time remapping expression does is control the playback of the movie. You can't change anything inside the movie (from the main comp), just the order and timing of the playback.

Dan

Votes

Translate

Translate
Community Expert ,
Oct 17, 2018 Oct 17, 2018

Copy link to clipboard

Copied

If what you're trying to do is have an action in the precomp look different depending on checkboxes in the main comp, I don't think that's possible. I think you'd have to create a new action in the precomp that's identical, except for which layers are visible.

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
New Here ,
Oct 17, 2018 Oct 17, 2018

Copy link to clipboard

Copied

Nono, the actions, markers and keyframes in the pre-comp are exactly the same on all of the layers. The checkboxes don't change those.

For instance, I have two arm layers in the pre-comp that are exactly the same dimensions with the only difference being that one has the hand of the character in a more "relaxed" position, the other in a wave position, and when adding a marker in the main comp both of them play out properly with no issues...

1.png

Now, my goal is to use the checkboxes from the main comp that are tied to this pre-comp to hide one of the layers while showing the other, swapping between them in a single frame to swap between hand gestures of the animated arms.

And it does do it. In the pre-comp the opacity changes at the right time in response to the keyframes of the switches, if the switch keyframe says at 0:15 hide RArmNormal and show RArmWave layers it works and in the pre-comp at 0:15 that exact thing happens.

However, in the main comp is where the issue resides...

2.png

This is the main comp, the selected layer is the pre-comp containing the 2 hand gesture layers and the action layer.

The layer above it is the checkbox layer with which i would like to control the opacity of the layers inside of the pre-comp.

Now, what ends up happening in the main comp is the following:

The animation of the RArmMotion marker starts playing, it's 30 seconds long, in the same timeframe are keyframes on the checkbox control layer that swap opacity between the RArmNormal and RArmWave layers, the first 3 keyframes (marked with the green line) are at 0, 10 and 15 seconds, this part of the main comp plays out perfectly and the opacity in both the maincomp and the pre-comp is swapped correctly at the correct times and plays exactly where I've marked them with the green line.

Then the second part of the animation comes with the RArmWave marker animation playing, this animation also has accompanying checkbox keyframes to go with it (the ones marked with blue), they are supposed to change the opacity of the pre-comp layers at 1:35 and 1:56, the marker animation plays correctly without any issues, but now the opacity of the keyframes marked blue doesn't play at 1:35 and 1:56 but plays a whole minute later where the red line is, at around 3:12, way later than the checkbox keyframes told it to.

So that's my issue. The checkbox animations DO play, but they're very delayed.

I am aware that I can most likely fix this issue by making individual pre-comps of each of the hand gestures in the main comp and adding the same exact keyframes and position properties onto all of them and then controlling the opacity layers of the individual pre-comps with the checkbox controls in the main comp, but this would cripple my workflow as I would have to add a large amount of keyframes and markers individually for each of the individual gesture pre-comps in the main comp.

I'm hoping there's a way to tell the code to ignore the opacity property so it doesn't delay it from playing in the main comp, since it DOES actually play out, but way later. Or of course some other way to get around this.

If there indeed is a way to change the code to get around this issue I would be very grateful, it would save me a ton of time and streamline things greatly.

Thank you!

Jeff

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 Expert ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

The only thing I can think of would be to move the opacity checkboxes into the precomp.

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
New Here ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

Sadly that didn't change anything. I guess I'm doing it the less streamlined longer way with individual precomps for individual gestures.

Thanks for your time anyway, and thank you for the amazing code!

Jeff

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 Expert ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

Really? I thought that would take care of it. If you make the layer transition part of the action inside the precomp it seems like that would have to work.

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
New Here ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

It gives me the same result that I've already had which is: the opacity animates perfectly in the precomp, but is delayed greatly in the main comp. If i disable the expression code, it animates perfectly at the correct time where the checkbox keyframes are at.

So it's definitelly something about the code that delays the checkbox created opacity keyframes in the main comp, just not quite sure what.

Oh and if I manually add keyframes for opacity in the precomp the play properly at the proper times in the main comp without delay, but obviously I'm trying to avoid that and streamline things as much as possible.

It's just a pretty strange issue overall.

Jeff

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 Expert ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

Now I'm more confused, because I assumed that putting the checkboxes in the precomp would be just like keyframing the opacity directly in that the checkbox keyframes would happen at the same time as the opacity keyframes (at the point in the precomp where you want the layers to switch). So now I'm thinking either that's not what you tried, or there's something else going on.

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
New Here ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

I've done it as you've said and I got the same result, but I think I finally figured out what is actually going on... Except I don't know how to get around it/fix it.

This is now the precomp

dan1.png

This is now the main comp

dan2.png

The 4th and 5th set of keyframes in the precomp are keyframed at around 1:38 and 1:58 but play in the main comp at 2:40 and 3:00

What I think is happening is the following:

dan3.png

The 4th and 5th keyframes of the precomp checkbox layer are delayed by exactly 1:02 from the position of the RArmTest2 marker(the blue arrow), which is the exact amount of time that the delay in the main comp is.

Meaning that I can't just use the checkbox keyframes to control opacity at it's own individual time, for instance 1:38 because it's tied to the expression code and to the latest action marker that's placed down in the precomp.

This complicates things by quite a bit and completely excludes the possiblity of me using this method to animate the opacity of multiple layers in a single precomp individually while using the current "Triggering Animations With Markers" code because their timing is relied entirelly upon the position of the markers. So unless the code can be edited to exclude the opacity property of the layers I'll have to do it with individual precomps in the main comp instead of just using a single one and controling the individual precomp opacity.

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 Expert ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

Yeah, the opacity changes would have to be baked into the actions. Think of the precomp as a pre-rendered movie--all my time remapping expression does is control the playback of the movie. You can't change anything inside the movie (from the main comp), just the order and timing of the playback.

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
New Here ,
Oct 18, 2018 Oct 18, 2018

Copy link to clipboard

Copied

LATEST

Yeah, understood. Thanks for the info.

Originally I was hoping that there's a way to exclude the opacity transform property from the expression but since there isn't I'm just gonna do it individually.

Thanks a lot for your time!

Jeff

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