Make cube rotate around its edge without having to keyframe the anchor point?
Copy link to clipboard
Copied
Hello! I'm in After Effects CC 2024 working to animate a cube which is meant to rotate multiple times around its furthermost edge, and the way I'm doing it is by keyframing the anchor point every time it does a full 90° rotation but it's impractical and inefficient – is there any way to do this without manually keyframing?
Here's a reference GIF for what I'm trying to achieve; made this real quick in another app to get the point across so it's not in the best quality...
Copy link to clipboard
Copied
This is an interesting and tricky problem. I've been tinkering with it for a couple of days and here's what I've got. If the layer is a solid with the anchor point centered, you can use a position expression like this to "roll" the square in accordance with the rotation property:
w = width;
r = Math.sqrt(2*w*w)/2;
a = rotation%90;
a += a < 0 ? 90 : 0;
n = Math.floor(rotation/90);
a0 = Math.PI*5/4;
a1 = Math.PI*7/4;
a2 = linear(a,0,90,a0,a1);
c0 = Math.cos(a0);
x = n*w + r*(Math.cos(a2) - c0);
s0 = Math.sin(a0);
y = r*(Math.sin(a2) - s0);
value + [x,y]
If you're using a square shape layer (with anchor point centered), you need to change the first line to this:
w = content("Rectangle Path 1").size[0];
Copy link to clipboard
Copied
Sorry for a late reply but I only got to touch the project now; this expression is doing exactly what I was attempting to achieve. Thank you so much for solving my problem!!

