Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Missing a moving target

  • Missing a moving target

    Posted by John Cuevas on November 20, 2009 at 8:40 pm

    Have a bow and arrow and a moving target(wiggle). The bow and arrow follow the target with this expression on rotation:

    shoot = thisLayer.index;
    dx = thisComp.layer("heart").transform.position[0]
    - transform.position[0];
    dy = thisComp.layer("heart").transform.position[1]
    - transform.position[1];
    radians = Math.atan2(dy,dx);
    follow = radiansToDegrees(radians);
    if (time < shoot) follow else thisComp.layer("cupid").transform.rotation.valueAtTime(shoot)

    To the arrow's position I've added:

    shootStart = thisLayer.index;
    shootFinish =thisLayer.index+1
    start = transform.position;
    finish =thisComp.layer("heart").transform.position.valueAtTime(shootStart)
    linear(time,shootStart,shootFinish,start,finish)

    My arrow shoots at the target and heads to the point where the target was correctly, but it stops when it gets there. I would like it to follow the same trajectory but extend past that point. Ideally the total distance travelled would always be the same(keeping the velocity the same). I'm planning to shoot the target multiple times, hence the indexing-once I get one arrow to do this right.

    Johnny Cuevas, Editor
    http://www.ckandco.net

    Chris Wright replied 16 years, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Chris Wright

    November 20, 2009 at 9:12 pm

    Sometimes you just want something to move constantly without keyframing it. Use throw.

    // Throw (move at a constant speed without keyframes)
    veloc = -10; //horizontal velocity (pixels per second)
    x = position[0] + (time – inPoint) *veloc;
    y = position[1];
    [x,y]

    https://technicolorsoftware.hostzi.com/

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy