FORUMS: list search recent posts

Using a null's position regardless of time

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mark Parayno
Using a null's position regardless of time
on Sep 2, 2011 at 10:03:55 pm

Hey Everyone,
I was wondering if you can help me out with this.

I want to build a comp with a null that has the position values that I want to use in with different layers that happen on different times on the timeline. Is there any way to use the position values of the null and mimic its motion even though the layers mimicking the the motion happens on different times on the timeline?

Thanks in advance everyone!


Return to posts index

Dan Ebberts
Re: Using a null's position regardless of time
on Sep 2, 2011 at 10:25:07 pm

I think you might mean something like this:

timeOffset = 3; // 3 seconds earlier than current time
thisComp.layer("Null 1").transform.position.valueAtTime(time-timeOffset)


Dan



Return to posts index

Mark Parayno
Re: Using a null's position regardless of time
on Sep 6, 2011 at 9:58:36 pm

Thanks for the reply. I'm actually looking to take that a step further. I trying to use markers to call the animation since I'm going to have multiple layers using that same animation on different times in the timeline. This is were I'm stuck: calling animation in on the marker "animate in" and calling an animation out on "animate out"

The help is greatly appreciated

timeOffset =.25
mOut=thisLayer.marker.key("animate out").time*1;
mIn=thisLayer.marker.key("animate in").time*1;

myComment = "animate in"

if (myComment = "animate in") { anni = time-mIn }
else (myComment = "animate out") { anni = time-mOut}


thisComp.layer("Position").transform.position.valueAtTime(anni-timeOffest);


Return to posts index


Mark Parayno
Re: Using a null's position regardless of time
on Sep 6, 2011 at 10:15:54 pm

Tried this, but no luck

mOut=thisLayer.marker.key("animate out").time*1;
mIn=thisLayer.marker.key("animate in").time*1;

myComment = thisLayer.marker;

if (myComment = "animate in") { anni = (time-mIn) };
if (myComment = "animate out") { anni = (time-mOut) };


thisComp.layer("Position").transform.position.valueAtTime(anni-.0);


Return to posts index

Mark Parayno
Re: Using a null's position regardless of time
on Sep 6, 2011 at 10:17:07 pm

Tried this with no luck

mOut=thisLayer.marker.key("animate out").time*1;
mIn=thisLayer.marker.key("animate in").time*1;

myComment = thisLayer.marker;

if (myComment = "animate in") { anni = (time-mIn) };
if (myComment = "animate out") { anni = (time-mOut) };


thisComp.layer("Position").transform.position.valueAtTime(anni-.0);


Return to posts index

Dan Ebberts
Re: Using a null's position regardless of time
on Sep 6, 2011 at 11:12:28 pm

I would think I should be able to figure out what you're trying to do, but I'm not getting it. In any case, there are some problems with your expression. When you do a comparison, you need to use ==, not =.
You're setting variable myComment to the layer marker object, so it's not going to match up with either of your text strings. I'm guessing that you really the comment from a particular marker, but which one? When you have sequential if statements like that, you need to be sure that one of them is always true, or you'll get an error. If that's the case, you would more commonly see it this way:


if (myComment == "animate in")
anni = time-mIn
else
anni = time-mOut;



or like this:

anni = time - (myComment == "animate in") ? mIn : mOut;


Dan



Return to posts index


Mark Parayno
Re: Using a null's position regardless of time
on Sep 6, 2011 at 11:50:18 pm

I hope this can clear up what I'm trying to do. Basically I have a bunch of layers that going to use the same animations, but just in different times in the timeline. So I want to use the a set of animations in my null layer to guide all the animations



Return to posts index

Dan Ebberts
Re: Using a null's position regardless of time
on Sep 7, 2011 at 12:18:35 am

Probably something like this:


n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time) n--;
}

if (n > 0){
t = time - marker.key(n).time;
myComment = marker.key(n).comment;
L = thisComp.layer("Position");
myTime = L.marker.key(myComment).time + t;
L.transform.position.valueAtTime(myTime);
}else{
value
}



Dan



Return to posts index

Mark Parayno
Re: Using a null's position regardless of time
on Sep 7, 2011 at 7:24:17 pm

So this is what I have that worked. is there a way to adapt the that and in the one you wrote. Thanks alot for the help! You're awesome.

Apologies for the mistakes, still a newb with it all. Your motionscript site is Great! Its really helping me try to wrap my head around expression.

timeOffset = 0


mOut=thisLayer.marker.key("animate out").time*1;
mIn=thisLayer.marker.key("animate in").time*1;


myComment = marker.nearestKey(time).comment;


if (myComment == "animate in")
comp("COMMON CONTROLS").layer("L1 In").transform.position.valueAtTime((time-mIn)-timeOffset);
if (myComment == "animate out")
comp("COMMON CONTROLS").layer("L1 Out").transform.position.valueAtTime((time-mOut)-timeOffset);


Return to posts index


Mark Parayno
Re: Using a null's position regardless of time
on Sep 8, 2011 at 9:04:10 pm

Hey all,
So I'm getting an error when I use this expression on position or scale.

This the error I get before I add any layer markers:
"after effects warning expression result must be of dimension 2 not 1"

Can anyone see what I'm doing wrong?

/* NAME OF TRANS */

/* LINK IN TRANS FROM COMMON CONTROLS COMP */
inAnimation = comp("* COMMON CONTROLS *").layer("L1 In")

/* LINK OUT TRANS FROM COMMON CONTROLS COMP */
outAnimation = comp("* COMMON CONTROLS *").layer("L1 Out")



if (marker.numKeys > 0){
/*VARIABLES*/
timeOffset = effect("Time Delay - Position")("Slider");
myComment = marker.nearestKey(time).comment;
myTime = marker.nearestKey(time).time;


if (myComment == "in")
inAnimation.transform.position.valueAtTime((time-myTime)-timeOffset);

if (myComment == "out")
outAnimation.transform.position.valueAtTime((time-myTime)-timeOffset);


}else{
value;
}


Return to posts index

Mark Parayno
Re: Using a null's position regardless of time
on Sep 8, 2011 at 9:17:26 pm

Hey all,
So I'm getting an error when I use this expression on position or scale.

This the error I get before I add any layer markers:
"after effects warning expression result must be of dimension 2 not 1"

Can anyone see what I'm doing wrong?

/* NAME OF TRANS */

/* LINK IN TRANS FROM COMMON CONTROLS COMP */
inAnimation = comp("* COMMON CONTROLS *").layer("L1 In")

/* LINK OUT TRANS FROM COMMON CONTROLS COMP */
outAnimation = comp("* COMMON CONTROLS *").layer("L1 Out")



if (marker.numKeys > 0){
/*VARIABLES*/
timeOffset = effect("Time Delay - Position")("Slider");
myComment = marker.nearestKey(time).comment;
myTime = marker.nearestKey(time).time;


if (myComment == "in")
inAnimation.transform.position.valueAtTime((time-myTime)-timeOffset);

if (myComment == "out")
outAnimation.transform.position.valueAtTime((time-myTime)-timeOffset);


}else{
value;
}


Return to posts index

Dan Ebberts
Re: Using a null's position regardless of time
on Sep 8, 2011 at 9:42:46 pm

That doesn't exactly make sense. I would expect you to get that error as soon as you add the first layer marker, but before it has a comment. Your expression doesn't handle that situation (nearest marker doesn't have a comment of "in" or "out". In that case it will use the last result it calculated, which is probably "myTime". You could probably get it to work by adding comments to all the markers, then re-enabling the expression, but that's not the right way to do it.

Your inner if/else clause needs to look like this (notice the single semicolon at the end):


if (myComment == "in")
inAnimation.transform.position.valueAtTime((time-myTime)-timeOffset)
else if (myComment == "out")
outAnimation.transform.position.valueAtTime((time-myTime)-timeOffset)
else
value;



Dan



Return to posts index

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