Fake Highlight Rotation View Comments

2:44 PM by , under , , , ,

Bookmark and Share

A friend of mine is currently working on a project in which there is a ball rolling on the floor and he needs to move the highlight in order to correspond to a light source in the distance. I came up with a quick solution, and I thought I'd share it in case you cross upon something similar, because I feel that this is something quite common, but I wasn't able to find anything on the net. You can download the AEP file here if needed.

Here is the result:


Basically, I created a null that acted as the fake position of our light. Then, I used this null's position to calculate the distance from the highlight on the X and Y axes and theoretically made a right triangle. Using each axis information, I plugged it all into an inverse tangent equation to give me the correct angle that I wanted. Then I just added a multiplier to increase/decrease the amount of rotation.

In this AEP file, I have 4 layers. The ground, the ball, the reflection, and the null. I animated the ball moving around in an arc that roughly imitates my friend's animation.

Want you want to do next is make sure that the Anchor Point for the highlight is in the center of the ball, that way when we rotate it, it will do so inside the ball. Then make sure to parent the highlight to the ball. Afterwards you want to Alt-Click on the Rotation stopwatch in the highlight layer to open up an expression box and type in the following code:


adjc = sub(thisComp.layer("nullLightSource").transform.position[0],thisComp.layer("ball").transform.position[0])
opp = sub(thisComp.layer("nullLightSource").transform.position[1],thisComp.layer("ball").transform.position[1])

sidesratio = div(opp,adjc)

inversetan = Math.atan(sidesratio)*25


Let's break this code down a little. The variable adjc takes the X axis info from the null called "nullLightSource" and subtracts it from the X pos of the layer called "ball". Similarly, opp takes the difference from the Y info. sidesratio then plugs these two correctly into the inverse tangent equation Math.atan().
Then I added a multiplier of 25 at the end of inversetan simply because it looked good.

And voila! You now have a highlight rotating based upon the position of a null. I'm sure somebody can come up with an even cooler application to this, maybe a giant axe blade attached to the end of a pendulum?



edit post