Try this expression:
Code:
restLength = 200;
damp = .97;
leader = thisComp.layer("leader2");
g = 0.5;
ks = 2;
fDur = thisComp.frameDuration;
currFrame = Math.round(time / fDur);
p2 = position.valueAtTime(0);
v2 = 0;
for (f = 0; f <= currFrame; f++){
t = f*fDur;
p1 = leader.position.valueAtTime(t);
delta = p2 - p1;
nDelta = normalize(delta);
a = ks * nDelta * (length(delta) - restLength) * fDur - [0,g,0];
v2 = (v2 - a) * damp;
p2 += v2;
}
p2
This expression is based on Dan Ebberts's "Elastic Connection" expression from:
http://www.motionscript.com/design-guide/elastic.htmlWhere I added a gravity factor (g) to the expression.
"leader2" is a layer positioned where you want the "rope" to be attached to.
If you are using parenting in order to rotate the "tree",
put a solid/null layer at the desired loaction on the "tree" and parent it to the tree. name that solid "leader".
Then create another solid/null, name it "leader2" and give it the position expression:
Code:
leader = thisComp.layer("leader");
leader.toWorld(leader.anchorPoint.valueAtTime(time))
Check out the attached project file, and play with the parameters of the expression.
Koby.
p.s.: this is not really a "rope" behaviour, it is actually a "spring" behavior.
But the behaviour is very similar to what you wanted.
To prevent oscilations at the beginning of the animation, place the object at distance equal to the "restLength" parameter in the above expression (that will prevent the spring from contracting).
If you are watching my projectfile, check the "distance" text layer, it calculates the distance between the "Card" layer and the "leader" layer.