Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
 
Copy link to clipboard
Copied
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:
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.
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now