Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Detect motion do action

  • Detect motion do action

    Posted by Mauro Di ianni on March 18, 2015 at 4:08 pm

    Hi folks! Long time lurker here, I finally had the need to show up myself.

    I’m trying to do this:

    I have trapcode particular generating lines from the movement of a light (actually of a null attached to a light).

    I’d like it to stop generating particles when there is no movement. I’d like it to be automated so I need expressions, I guess.

    I’m thinking about an IF/THEN statement like:

    IF the null position value changes THEN particles/sec = N, ELSE particles/sec = 0.

    Any hints on how to write it? Maybe I can check if there’s movement by subtracting the position value at each frame with the value of the frame before, if it equals zero then there is no movement. Or maybe there’s some pertinent expressions for this purpose.

    Any suggestions will be much appreciated, thanks a lot!

    Mauro.

    Mauro Di ianni replied 11 years, 4 months ago 2 Members · 5 Replies
  • 5 Replies
  • Mauro Di ianni

    March 18, 2015 at 5:18 pm

    This is what I did so far but it gives me an error at line 5 “illegal use of reserved word”.

    Any suggestions?

    Thanks.

    M.

    delta = thisComp.frameDuration/25;

    if (thisComp.layer("Null_controller_iPhone").transform.position.valueAtTime(time-delta)) -
    (thisComp.layer("Null_controller_iPhone").transform.position.valueAtTime(time)) == 0 {0}
    else {};

  • Dan Ebberts

    March 18, 2015 at 5:24 pm

    Something like this, I think:

    s = thisComp.layer(“Null 1”).transform.position.speed;
    if (s > 0) 100 else 0

    Dan

  • Mauro Di ianni

    March 18, 2015 at 6:04 pm

    Thanks Dan!

    So basicly position.speed detects any changes? Unfortunately this doesn’t seem to work in my case though, I don’t know why…

    I had to put in the speed rotation also, because it’s animated aswell.

    This gives me very weird results, it mostly stays at 10000 and in proximity of few keyframes it turns to 0 for a single frame…

    The null animation is not very complex.

    Could it be something related to the easy ease keyframes? It looks like it detects speed even between two keyframes that have the same values. The animation doesn’t move at all between them but maybe the easy ease interpolation makes the expression think that there is some speed data.

    s = thisComp.layer("Null_controller_iPhone").transform.position.speed;

    r = thisComp.layer("Null_controller_iPhone").transform.yRotation.speed;

    if ((s > 0) || (r >0)) 10000 else 0;

  • Dan Ebberts

    March 18, 2015 at 6:27 pm

    It’s hard to say without seeing it, but it might be that the speed is close to zero, but not exactly zero, so you might need to check for a range of values near zero. One thing that happened to me when I was playing with it is that the caching system got confused and I had to purge memory and then do a ram preview to get it to work right.

    Dan

  • Mauro Di ianni

    March 19, 2015 at 1:20 pm

    I need to do further testing but changing the value from 0 to 0.5 seems like did the trick. Thanks a lot!

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