FORUMS: list search recent posts

Expression: OBJ 2 moves right when OBJ 1 moves left.....

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Van Garmon
Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 3:35:05 am

I am trying to come up with what I would think to be a simple expression.

I have one object "A" that when it moves to the left my second object "B" would move to the right. Can anyone give me any pointers on getting the correct expression to get them to move in opposite directions?

I have parented one to the other but of course both objects go in the same direction.

Any help would be appreciated.

Thanks in advance.


Return to posts index

Dan Ebberts
Re: Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 4:41:41 am

You need to define some sort of reference point. One way would be to use the position of object "A" at time zero. This should work for that situation:

p = thisComp.layer("A").transform.position;
value - [(p-p.valueAtTime(0))[0],0]

Note that you won't see anything happen until you generate some horizontal movement for object A (via keyframes or expression).

Dan



Return to posts index

Van Garmon
Re: Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 2:04:39 pm

so if I put the above expression in the position "P" of object "B" object "B" should move opposite of object "A"s position??

p = thisComp.layer("A").transform.position;
value - [(p-p.valueAtTime(0))[0],0]


Return to posts index


Van Garmon
Re: Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 2:07:20 pm

This does not work. Both objects move in the same direction.


Return to posts index

Van Garmon
Re: Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 2:09:58 pm

Update...

using the above expression does not have any movement when moving the other object.


Return to posts index

Dan Ebberts
Re: Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 4:34:56 pm

Did you keyframe the movement of the leader object?

There's another way to do it if there's a reference point (center of the comp) so that one layer mirrors the position of the other relative to the reference x value. I don't know if that would work for you.

Dan



Return to posts index


Van Garmon
Re: Expression: OBJ 2 moves right when OBJ 1 moves left.....
on May 14, 2013 at 5:07:45 pm

When it comes to expressions I am not the best. I will do the movement "manually" with key frames and time it out.

Thanks for the suggestions gang.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]