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

linking shape layer size to position of another layer

New Here ,
Jan 03, 2021 Jan 03, 2021

hi guys ive been trying to get a solution to this (see attatched)

id like the box size to be linked to the position of the shirt image, so that when the shirt moves towards the right side, the box size increases,

also, the box left side position should remain constant so that the box "expands" towards the right

any help will be gladly appreciated

TOPICS
Expressions , How to
3.7K
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
Valorous Hero ,
Jan 04, 2021 Jan 04, 2021

I can't upload a .aep file for you, but here's a screenshot showing the code (along with explanation via comments) for a simple rig that allowed me to grow the box based on the star's position, while being fixed to the left side of the box.

 

Note that the star is parented to a null that's in the same coordinates that the star started out in. This allows the new relative coordinates of the star to be [0,0] which means the math is easier when calculating the distance the star travels. i.e. the star moves 100 pixels to the right of the center and its xPosition is now 100 instead of 1060 (this is a 1920x1080 comp, so the original position of the star in the center is [960,540].

 

This null (which I hid) along with the Box are then both parented to a Global Controller null, also placed in the center, which allows you to move the whole rig without screwing anything up. I also placed a slider on that controller which limits how far out on the x-axis the star can move. I put the clamp() function on the xPositon of the star so it can't move any less than 0 (which would be to the left of the box) and it can't move any further right than the number specified on this slider. You don't have to use the slider, or you can set it to a really large number, but it adds more flexibility to your rig.

 

When working with the box shape layer, make sure to only use the shape's Size and Position parameters, not the layer's scale or position. The easiest way to set this up is to double click the Rectangle Tool icon in the top toolbar to make a shape layer that's the full size of your comp, then twirl down the properties and only work with the Rectangle's Size and Position.

 

Even though there is an expression on the star's position you can still move it by either dragging the star itself (make sure not to select the null in the comp panel) or you can scrub the xPosition in the timeline.

 

You should be able to recreate this rig and adapt it to your t-shirt image.

 

Growing Box.jpg

Growing Box2.png

 

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 ,
Jan 04, 2021 Jan 04, 2021
LATEST

I would set up the comp as simply as it could be setup. If you are using shape layers then simply tying the left edge of a rectangle to the position of another layer or another object in the shape layer is really easy. If your shirt layer is an image layer and your rectangle is a mask you can easily tie the top and bottom right corners to a null using the create nulls from paths script that comes with AE and parent the left and right nulls to the position of the other layer. The script will take care of writing the expressions for you. Here's a step by step showing how to do that using an image of a shirt on one layer and a shape layer with a rectangle for the background rectangle:

  1. Add your shirt image to the timeline and position it as needed
  2. Add a shape layer below the shirt layer with a bezier path rectangle. You can use the Rectangle tool with Bezier Path turned off and convert it later or you can check Bezier Path when you draw the rectangle
  3. Position the background layer where you need it, press UU to reveal all modified properties of the background layer, select the path and open Window/Create Nulls From Paths.jsx and select Points follow nulls.
  4. This will give you a comp with four shape layer nulls above the background and the shirt layer on top (Layer 1). 
  5. Select the top right and bottom right nulls, move them to the top of the timeline and parent them both to the Shirt layer
  6. Animate the position of the Shirt layer to move the right edge of the rectangle to the right side of the screen

 

If you need to do any more adjustment of the shirt layer/background layer in the comp add another null, name it Background Position, then parent the other shape layer nulls and the background layer to the position null. That's all there is to it. It will take you about 5 minutes.

ShirtBox.gif

Here's a project file for you to play with.

 

If you need more help please embed your screenshots using the toolbar instead of uploading them.

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