ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Movement started by multiple Marker

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dominique Parisi
Movement started by multiple Marker
on Feb 14, 2020 at 1:55:32 pm

Hi !

I'm trying to set up an animation tool aimed to be used quite regularly.
I've done a lot by myself by trial and error, but being quite a novice about coding, I'm turning to you.

What the expression is suppose to do is moving, a comp along the Y axis, by 500px, when it hit a marker "Move" and move it depending of the marker.duration.
The movement value will depend on the composition height ( which changes depending of the project i'm on. So it has to be manually specified.)

Then, when it hit's another "Move" marker, the movement continue from the position it reached and add again the + 500px


marker1 => 0 to 500,
marker2 => 500 to 1000
marker 3 => 1000 to 1500 and so on...

I was thinking using the marker index to multiply the end position.
what I got from reading on the board is the expression move once, then go back to 0 and redo the movement.

// move = 500*marker.nearestKey(time).index => what I though might works, but, it's start from 0 and go to 1500 if it's 3rd marker.

Thank you for any help and advice of related post I might have missed :)

***
// Set the position of the object
mainPos = comp("_CONTROL_PANNEL_CTRL").layer("Obj_Position_CTRL").effect("Obj_Position_Start")("Slider");

// Set the Object Vertical Offset
offsetPos = comp("_CONTROL_PANNEL_CTRL").layer("Obj_Vertical_Offset_CTRL").effect("Obj1-Vertical-Position_CTLR")("Slider");

// Object start position by combining mainPos and offestPos
yPOS = mainPos + offsetPos;


m = 0;
t = time;
Move = 500;

if (marker.numKeys > 0) {
m = marker.nearestKey(time).index;
tag = marker.key(m).comment;
if (tag == "Move") { t = time - marker.key(m).time }
linear(t, 0, marker.nearestKey(m).duration, yPOS, Move)
}


Return to posts index

Dan Ebberts
Re: Movement started by multiple Marker
on Feb 14, 2020 at 11:44:09 pm

I'm not 100% sure from your description, but I think it will look something like this:


moveAmt = 500;
m = marker;
val = value;
if (m.numKeys > 0) {
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
accum = 0;
y = 0;
if (n > 0){
if ( n > 1){
for (i = 1; i < n; i++){
if (m.key(i).comment == "Move") accum += moveAmt
}
}
if (m.key(n).comment == "Move"){
t = time - m.key(n).time;
y = linear(t,0,m.key(n).duration,0,moveAmt);
}
val = value + y + accum;
}
}
val



Dan



Return to posts index

Dan Ebberts
Re: Movement started by multiple Marker
on Feb 14, 2020 at 11:51:19 pm

This is better if you have any Move markers that have zero duration:


moveAmt = 500;
m = marker;
val = value;
if (m.numKeys > 0) {
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
accum = 0;
y = 0;
if (n > 0){
if ( n > 1){
for (i = 1; i < n; i++){
if (m.key(i).comment == "Move") accum += moveAmt
}
}
if (m.key(n).comment == "Move"){
t = time - m.key(n).time;
y = (m.key(n).duration > 0) ? linear(t,0,m.key(n).duration,0,moveAmt) : moveAmt;
}
val = value + y + accum;
}
}
val



Dan



Return to posts index


Dominique Parisi
Re: Movement started by multiple Marker
on Feb 15, 2020 at 9:19:19 am

All right !


Thx, I'll try this as soon as possible and get back to you !

All th best !


Return to posts index

Dominique Parisi
Re: Movement started by multiple Marker
on Feb 17, 2020 at 7:19:09 am

At last, I finally tested it !

I works like a charm ! Thank you so much for the help, good sir !.

many thx !

All the best


Return to posts index

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