-
Issue with updating a “Trim Paths” offset property value. I am at a loss :/
- Hey. I’m somewhat a beginner here with AE expressions. Over the past few days I’ve been working out how to write an expression in the “Trim Paths” offset property. Basically, I have a null with a checkbox as my on/off switch, which tells when the offset property should rotate. Through the null I also control the cycle duration (how many secs for the offset to reach 360) and the starting angle (0). I also have a way that works (if a bit untidy) that returns the previous and next keyframe on the checkbox property. I use this to grab the offset angle 1 frame before the checkbox goes off, so the offset pauses – rather than resets to 0 (my starting angle).
The problem I am having is that I cannot seem to have the offset update with this, even though when I look at the result (defAngle) through a source text layer and it gives the value I would expect. I can even manually type in the correct value and it works, but that does defeat the point of being dynamic.
I just cannot work out what the issue is, so any help would be appreciated if possible.
Here’s the expression in full:
- check = thisComp.layer(“Spotlight Control”).effect(“Play (1st key)”)(“Checkbox”);
cNum = check.numKeys;
kTime = check.nearestKey(time);//to calculate the previous and next keys relative to the current time
if (kTime.time <= time) { kpNum = kTime.index;
} else { if (kTime.index – 1 == 0) { kpNum = kTime.index;
} else { kpNum = kTime.index – 1;
} };
if (kTime.time >= time) {
knNum = kTime.index;
} else { if (kTime.index + 1 > cNum) { knNum = kTime.index;
} else { knNum = kTime.index + 1;
} };
if(knNum == 1) { prevK = inPoint;
} else { prevK = check.key(kpNum).time;
};
if(kpNum == cNum) { nextK = outPoint;
} else { nextK = check.key(knNum).time;
};mDur = thisComp.layer(“Spotlight Control”).effect(“Cycle Duration (sec)”)(“Slider”);
t = time – prevK;
mID = Math.floor(t / mDur) + 1;
tStart = mID * mDur;
tEnd = (mID + 1) * mDur;
currAngle = content(“Trim Paths 1”).offset;if(check == 1 && prevK != inPoint) {
defAngle = thisComp.layer(“Spotlight Control”).effect(“Angle A”)(“Slider”);
angleCycle = defAngle + 360;
} else { defAngle = currAngle.valueAtTime(framesToTime((timeToFrames(prevK) – 1)));angleCycle = defAngle;
};linear(t, tStart – mDur, tEnd – mDur, [defAngle], [angleCycle]);
- Hey. I’m somewhat a beginner here with AE expressions. Over the past few days I’ve been working out how to write an expression in the “Trim Paths” offset property. Basically, I have a null with a checkbox as my on/off switch, which tells when the offset property should rotate. Through the null I also control the cycle duration (how many secs for the offset to reach 360) and the starting angle (0). I also have a way that works (if a bit untidy) that returns the previous and next keyframe on the checkbox property. I use this to grab the offset angle 1 frame before the checkbox goes off, so the offset pauses – rather than resets to 0 (my starting angle).