Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Bringing a layer forward via expression in After Effects

Explorer ,
May 23, 2023 May 23, 2023

I'm relatively new to After Effects, but I've searched quite a bit and can't figure this out.

 

I have two solids right next to each other.  At certain points in the timeline, I'll increase the scale of one or the other for emphasis - making it pop out for a second and then return to normal size.

 

This works just fine for the solid layer on top, but the lower layer gets partially blocked.  I thought it would be trivial to move the lower layer up when needed via expressions, but I can't find a way to do that.

TOPICS
Expressions
868
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 23, 2023 May 23, 2023

That's just how 2D layers work in After Effects. Moving a layer on top of another in the layer stack can't be done by expressions, only scrpiting, but in your case that wouldn't work anyway since it needs to switch back and forth.

 

Easiest fix is make them 3D layers instead. Or you could have a Background and Foreground versions of one of the layers and toggle on and off their opacity as needed.

Translate
Community Expert , May 23, 2023 May 23, 2023

You can only use expressions on properties that you can keyframe. Layer Order is not one of those properties. 

 

If you make the layers 3D and animate the Z position of the layer, you want to move in front of the other. Moving a layer closer to the camera has the same effect as increasing the scale, but the speed of the transformation is more natural.

 

If you want to stick with 2D, you could add animated masks or use a copy of one of the animated layers as a track matte for the other.

Translate
Community Expert ,
May 23, 2023 May 23, 2023

That's just how 2D layers work in After Effects. Moving a layer on top of another in the layer stack can't be done by expressions, only scrpiting, but in your case that wouldn't work anyway since it needs to switch back and forth.

 

Easiest fix is make them 3D layers instead. Or you could have a Background and Foreground versions of one of the layers and toggle on and off their opacity as needed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2025 Feb 11, 2025

This thread is a couple years old, but this is exactly what I want to do...move a layer on top of another....Would I be able to make the bottom layer "push" through the text layer above it with a script?  If so, how would I go about figuring out how to write it?  Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 11, 2025 Feb 11, 2025
LATEST

Yes, changing layer index in After Effects is simple in scripting with moveAfter() and moveBefore()

 

https://ae-scripting.docsforadobe.dev/layer/layer/?h=moveafter#layermoveafter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2023 May 23, 2023

You can only use expressions on properties that you can keyframe. Layer Order is not one of those properties. 

 

If you make the layers 3D and animate the Z position of the layer, you want to move in front of the other. Moving a layer closer to the camera has the same effect as increasing the scale, but the speed of the transformation is more natural.

 

If you want to stick with 2D, you could add animated masks or use a copy of one of the animated layers as a track matte for the other.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 23, 2023 May 23, 2023

Thank you, both.  That makes perfect sense.  For a quick fix I'll probably just duplicate the layer and change its opacity when I need to animate, but it sound like 3D is the "right" way to manage this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines