Charlie Laud
Forum Replies Created
-
Charlie Laud
December 5, 2020 at 12:13 am in reply to: Controlling clones of an object in multiple scaled precompsAmazing, this works perfectly. Thank you so much!
-
Alright, so far so good!
Now I need to find a way to access the transform properties of the shape itself (not the layer transforms) to copy that data into the new shape as well. (i.e. take the shape Position and Anchor Points and add them to the new shape.)
What would the code for that be? I’ve been trying to use the documentation to help with this, but it doesn’t seem to provide a clear enough picture of how these hierarchies are structured, so thanks in advance for your help!
-
Perfect! Thanks for your help Dan!!
-
Or better yet –
Is there a way to create a “custom” shape from an array of points? That way I could copy the values from an existing shape, and create a new shape with slightly modified versions of those values.
-
This will take a string with a minute:second format and convert it to a frame number, depending on your frame rate:
myString = ;
frameRate = 1/thisComp.frameDuration;
timeArray = myString.split(":");
numFrames = (timeArray[0]*60*frameRate) + (timeArray[1]*frameRate) -
Charlie Laud
July 3, 2017 at 2:52 pm in reply to: following a path with an expression to swap compositions based on path direction, orientation or rotation?Here’s what I came up with!
Basically if you precompose all the sprites into one preComp, (each sprite gets its own frame), you can enable time remapping on that preComp layer and use some lines of code to “tell” it to cycle through each different set of sprites depending on the direction your sprite is moving. That’s as simple as using the valueAtTime() to find the difference between some position value at “current frame” and “current frame – 1”.
So precompose all those sprites in one layer. Right click on the layer and select Time> Enable Time Remapping and add this code:
directionNum = 0;
dX = transform.xPosition.valueAtTime(time) - transform.xPosition.valueAtTime(time - framesToTime(1));
dY = transform.yPosition.valueAtTime(time) - transform.yPosition.valueAtTime(time - framesToTime(1));if (dX > 0) {directionNum = 8;}
if (dX < 0) {directionNum = 4;}
if (dY > 0) {directionNum = 0;}
if (dY < 0) {directionNum = 12;}
framesToTime(directionNum + (timeToFrames(time) % 4))NOTE: you’ll have to Separate Dimensions on the position value, and it doesn’t seem to be too happy with anything other than linear keyframes. For some reason keeping the dimensions together was giving me some big ol trouble.
Hope this helps! Or is at least enough to get you started!
-
Hey Vojtech,
If I’m understanding this correctly, the modulus operator (%) should be able to help!
transform.rotation % (360*80)The above code would reset transform.rotation back to 0 every time it reaches a value higher than 360 * 80. So if you put
% (360*80)at the end of your expression, it will continuously keep the return value from exceeding the upper limit of the evolution parameter.You might be able to eliminate keyframes entirely with something like this:
updateFreq = 24; //step forward every 24 frames
radialStepValue = 30; //by 30 degrees
(Math.floor(timeToFrames(time/update Freq))*radialStepValue) % (360*80) -
Charlie Laud
June 30, 2017 at 12:33 pm in reply to: Is there a way to get expressions to ignore the number of rotations?Hey Josh,
It might be as simple as throwing a modulus operator (%) after your rotation value:
transform.rotation % 360That should re-evaluate to zero every time you pass 360!