ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

connect rotation value to number generator

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Eric Suquet
connect rotation value to number generator
on Jun 3, 2020 at 2:37:33 pm

Hello,

I'm an experienced AE user, but relatively in the dark when it comes to expressions. I don't code at all, and have only ever used the pickwhip for basic stuff. I need to connect the rotation of a dial to a number generator and have it be accurate. I can do it with the pickwhip, but I don't get the right values.

I've attached a basic picture of the comp. When the arrow is at 0 rotation, I need the numbers to be 50 and 50. When it is at -90 rotation, I need them at 100 and 0 etc...

Can someone help out? I don't have time to spend all day muddling it out myself, even though that's the best way to learn.



Return to posts index

Andrei Popa
Re: connect rotation value to number generator
on Jun 3, 2020 at 2:51:23 pm

I think you need to link a number to another and the line to only one of the numbers. Let's say you link it to the one on the left. This should work. The "leftNumber" is the number of the layer on the left.
This expression goes to the rotation of your needle

numberVal = thisComp.layer("leftNumber").text.sourceText.value;
linear(numberVal,0,100,-90,90)


The right number should have this to it's text, so it automatically updates to the one on the left:


numberVal = parseInt(thisComp.layer("leftNumber").text.sourceText.value);
100-numberVal;

Andrei
My Envato portfolio.


Return to posts index

Eric Suquet
Re: connect rotation value to number generator
on Jun 3, 2020 at 3:28:07 pm

Thank you for responding so quickly.

I am having trouble implementing this though.

For reference I have named the left number LEFT and the right RIGHT. I applied this to the the arrow rotation:


and the results are similar to when I just pickwhip it. How do i get the number offset to be correct? this should be more like +65%


And then I can't get the right number to connect at all to the left. I get this error:


Return to posts index


Eric Suquet
Re: connect rotation value to number generator
on Jun 3, 2020 at 3:34:11 pm

sorry, the second image should be this:




Return to posts index

Robert Müller
Re: connect rotation value to number generator
on Jun 3, 2020 at 3:32:59 pm

Hm wouldnt this affect the rotation of the needle based on the text value and not the other way around, since the expression is on the rotation of the needle?

I think it would be easier with these expressions.
For the left text:
Math.round(linear(thisComp.layer("needle").transform.rotation,-90,90,100,0))

And for the right text I just switched the mapped values:
Math.round(linear(thisComp.layer("needle").transform.rotation,-90,90,0,100))
I added the "Math.round" so that you'll get clean values


Return to posts index

Eric Suquet
Re: connect rotation value to number generator
on Jun 3, 2020 at 3:37:50 pm

That worked wonderfully. THANKS!



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]