Skip to main content
Participant
March 2, 2025
Question

Make cube rotate around its edge without having to keyframe the anchor point?

  • March 2, 2025
  • 1 reply
  • 329 views

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...

 

 

1 reply

Dan Ebberts
Community Expert
Community Expert
March 4, 2025

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];

 

 

Hyre__Author
Participant
March 12, 2025

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!!