1100 posts inlifethrill
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 more
InlifeThrill says

Based on the image by EFEKT : why dont you first mask the object.. like make a regular rectangle mask with no rotation what so ever, then rotate the layer itself 45 degrees.. thus making the mask and the axis rotate too. This will make it easy to move the object diagonally by adjusting the X value. Visually you get the same thing.

-inlife

2350 posts Small, but tough
  • Has referred 500+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+9 more
EFEKT_Studio says

Hey!

I’ve made a little project file for you :)

2 Points

  • Starting Point
  • Ending Point
  • Control

  • Percent
  • Preview

    Conclusion

  • Adjust the point, select the object layer and in the effects panel play with the “Percent” value to get it moving between the lines. :)
  • Expressions

    per = effect("Percent")("Slider");
    
    if(per <= 0) { per = 0.001; }
    
    start = thisComp.layer("Starting Point").transform.position;
    end = thisComp.layer("Ending Point").transform.position;
    
    dx = end[0] - start[0]; //replace minus with the simbol, forum wont display it correctly :S
    
    dy = end[1] (minus) start[1]; //here also
    
    [dx * per + start[0] , dy * per + start[1]]
    

    This is a very simple expressions. First i calculate the difference in x and y values between the point. Then i simply multiply the values with the “Percent” and add that value to the Starting Point.

    Download

  • Download *.AEP for After Effects CS4
  • Nice one man! Besides this, could be useful for other stuff too.

    @inlife, I know all that, but I’m too stubborn. I want to do this the easiest possible way :)

    5076 posts
    • Elite Author: Sold more than $75,000 on Envato Market
    • Has sold $125,000+ on Envato Market
    • Has been part of the Envato Community for over 5 years
    • Helps us moderate the forums
    +11 more
    felt_tips Volunteer moderator says

    Mo’s bang on with that expression.

    The 45 degree thing is all about linking the x and y move together and offsetting by the original position. For a 45 degree move, x = y. For a different angle the relationship changes. You can use trigonometry to find the relationship.

    Below is an expression that does a similar thing, but instead of using Mo’s start and end position, it uses an angle of movement given by an Angle Control expression controller effect on the layer (along side the Slider Control that adjusts the extent of the movement). Note that angles need to be converted from degrees into radians before you can use trigonometrical functions on them. This is just the way of things.

    origPos = value;
    amt = effect("Slider Control")(1);
    ang = degreesToRadians(effect("Angle Control")(1));
    move = [-Math.sin(ang), Math.cos(ang)];
    origPos + amt*move;
    
    @Mo. You’d only need the line…
    if(per <= 0) { per = 0.001; }
    
    ...if you were dividing by per. Seeing as you’re multiplying, it’s irrelevant.
    1100 posts inlifethrill
    • Has referred 200+ members
    • Has sold $250,000+ on Envato Market
    • Has collected 10+ items on Envato Market
    • Elite Author: Sold more than $75,000 on Envato Market
    +10 more
    InlifeThrill says

    Hey, is there a way to fix the range of an expression slider control.. say from 0 to 100.. or 50 to 100. Now they are like.. 0 to (too much). Same question for the other expression controls.

    -inlife

    5076 posts
    • Elite Author: Sold more than $75,000 on Envato Market
    • Has sold $125,000+ on Envato Market
    • Has been part of the Envato Community for over 5 years
    • Helps us moderate the forums
    +11 more
    felt_tips Volunteer moderator says

    Hey, is there a way to fix the range of an expression slider control.. say from 0 to 100.. or 50 to 100. Now they are like.. 0 to (too much). Same question for the other expression controls. -inlife

    Like this…

    linear(value, 0, 100, 0, 100);
    

    ...fixes to minimum 0, maximum 100. Change the values for a different fix. If you just want to fix one end, just adjust one of the values to a ludicrously high or low number. Alternatively use…

    value<12 ? 12 : value;
    

    ... clamps value to greater than 12

    value>103 ? 103 :value;
    

    ...clamps value to less than 103

    for a point control, it looks like this…

    [linear(value[0], -50, 50, -50, 50), linear(value[1], 0,1000, 0,1000)];
    

    ..clamps the first value to between -50 and +50 and the second to between 0 and 1000

    1100 posts inlifethrill
    • Has referred 200+ members
    • Has sold $250,000+ on Envato Market
    • Has collected 10+ items on Envato Market
    • Elite Author: Sold more than $75,000 on Envato Market
    +10 more
    InlifeThrill says

    Ah cool stuff. I’ve used the linear before but never though of it right here. That’s why I suck at math. Thanks Ben. Saved the day.. again.

    -inlife

    2350 posts Small, but tough
    • Has referred 500+ members
    • Has sold $125,000+ on Envato Market
    • Has been a beta tester for an Envato feature
    • Has collected 100+ items on Envato Market
    +9 more
    EFEKT_Studio says

    @mocarg, @felt_tips – thank you very much guys.. Cannot try it properly now, my computer is going to die soon. :( Time for refreshment :)

    by
    by
    by
    by
    by
    by