Skip to main content
Inspiring
Dec 4, 2026 3:34 AM UTC
Question

How do I make an object rock back and forth?

I’ve got a simple text layer parented to this “egg” shape layer that I’d like to rock back and forth (just like an egg or a rocking horse)… How can I accomplish this? It’s as if the anchor point needs to always be on the blue guideline as the egg rocks back and forth. I couldn’t articulate the question well enough when searching for an answer… Any ideas? Thank you all!

    6 replies

    Nishu Kushwaha
    Community Manager
    Community Manager
    Dec 4, 2026 4:27 PM UTC

    Thanks, CORCTON, for the clear explanation - placing the anchor point at the egg’s base is the key.

    I also used the new After Effects AI Assistant to create a sample project demonstrating the rocking motion. It took just a short time and used 38 credits. I’ve attached the project file here if you’d like to take a look.

     

    Thanks,
    Nishu

    Translate
    Inspiring
    Dec 4, 2026 5:20 PM UTC

    Much appreciated, Nishu! I appreciate you sharing the project so I can take a look. This is rocking how I was hoping for. 

    Forgive my ignorance, I have yet to use AI assistant and have little experience implementing slider controls and expressions.. 

    Was this all created using AI Assistant? 

    Is there a way for me to manually add these parameters to my project? Especially the “roll radius matches the egg’s base curve)

    I’d love to know how to do this for my own knowledge (unless using AI is the status quo for motion designers nowadays)

    Thanks again!

     

    UPDATE*****************

    I’m figuring out in real time how to add these parameters to my project.. I need the challenge so I can learn :) Thanks again!

    Translate
    CORCTON
    Community Expert
    Community Expert
    Dec 4, 2026 6:10 AM UTC

    Hi — you're thinking about it exactly right: the anchor point is the key. A layer rotates around its anchor point, so if you put the anchor point at the bottom of the egg, the egg will rock on the ground instead of spinning around its middle.

     

    1. Move the anchor point to the bottom: select the egg shape layer, press Y to switch to the Pan Behind (Anchor Point) tool, and drag the anchor point down to the bottom center of the egg — right where it touches the ground (your blue guideline). Since your text layer is parented to the egg, it will follow along.

    2. Animate the rock: with the egg layer selected, press R to show Rotation, and set two keyframes — for example, -12° at 0:00 and +12° at 1:00. Select both keyframes and press F9 to Easy Ease them, so the rock slows down at each end, like a real rocking horse.

    3. Keep it rocking forever: Alt-click (Option-click on Mac) the Rotation stopwatch and type this expression:

    loopOut("pingpong")

    That repeats your two keyframes back and forth. Make the angle bigger for a wider rock, or the keyframes further apart for a slower rock.

     

    Adobe's expression reference explains loopOut and the "pingpong" type here: https://helpx.adobe.com/after-effects/desktop/work-with-expressions/expression-language-reference/expression-language-reference.html

    Translate
    Inspiring
    Dec 4, 2026 5:07 PM UTC

    Thank you so much for you clear explanation, Corcton. 

    I did in fact try this earlier, but I think I ran into an issue with it looking more realistic because as an egg rocks, it almost travels a bit due to its asymmetrical shape. I put an egg on my counter and watched it closely haha.. 

    Am I missing something from your explanation that makes this possible? 

    Translate
    CORCTON
    Community Expert
    Community Expert
    Dec 5, 2026 12:04 AM UTC

    You’re not missing anything — you’re right, and that’s a sharp observation. A pure rotation around a fixed anchor point looks pinned, because a real egg’s contact point travels as it rocks.

    Add that travel to the same setup:

    1. Keep the anchor point at the bottom, and keep your two Rotation keyframes with loopOut(“pingpong”).
    2. 2. Alt-click (Option-click on Mac) the Position stopwatch and type this expression:
     

    r = 60;x = value[0] + r * thisLayer.rotation * Math.PI / 180;[x, value[1]]

    That moves the egg sideways by the arc length (radius × angle) as it rotates, so it rolls instead of spinning in place. The 60 is the approximate radius of the egg’s base curve in pixels — tune it until it looks right; a bigger number travels further.

    Since the egg is asymmetrical, that radius is only an approximation, so keep the rocking angle small (around ±10–15°) and it will read as a natural rock. Your parented text layer will follow automatically.

     

     

     

     

     

    Translate