Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Motionscript ? for Dan

  • Motionscript ? for Dan

    Posted by Eric Sanderson on October 6, 2008 at 7:39 pm

    Hey Dan, ive been putting together an abstract graphic piece based on your random motion in an x,y,z grid script on your site. I just pre-comped 6 3d planes making a 3d cube and used that comp as the object to duplicate along the grid. Everything works beautifully until i go to apply motion blur, it gives me an error saying

    “After EFfects warning: Class “Layer” has no property or method named “start”
    Expression disabled.

    ive collapsed transformations on the precomp so i can move around it in 3d in my master comp. And this error happens after ive enabled motion blur inside my pre-comp, then click back to the master comp. Ive also added this code to the scale:

    probability =20;
    r = (random(-probability+2,1)); //determines how often it wiggles, -4,1= 1/6th of the time with a clamp of 0,1
    v = clamp(r,0,1);
    s = wiggle(10, 500*v);
    x = s[0];
    y = s[1];

    [x,y]

    : but the error says it takes place on the cubes position. Seems very strange to me that motion blur can affect the code this way. Any ideas?

    Dan Ebberts replied 17 years, 7 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    October 6, 2008 at 8:21 pm

    I can’t duplicate the problem, but maybe motion blur causes AE to access frames before time 0, and I cleverly set up the code that “start” isn’t defined in that case. Also, I shouldn’t have used “start” as a variable name because it is also layer attribute. Try this version and let me know if it works better for you. I need to clean it up on my site.

    origin = [10,10,0]; //upper left hand corner of grid
    dimX = 8; //number of columns
    dimY = 6; //number of rows
    dimZ = 6; //number of planes
    gap = 20; // distance between cells (pixels)
    gridRate = 250; //speed (pixels per second)
    holdTime = .2; //(seconds)

    end = 0;
    strt = 0;
    j = 0;

    while (time >= end){
    seedRandom(j,true);
    startX = Math.floor(random(dimX))*gap + origin[0];
    startY = Math.floor(random(dimY))*gap + origin[1];
    startZ = Math.floor(random(dimZ))*gap + origin[2];
    j +=1;
    seedRandom(j,true)
    strt = end;
    endX = Math.floor(random(dimX))*gap + origin[0];
    endY = Math.floor(random(dimY))*gap + origin[1];
    endZ = Math.floor(random(dimZ))*gap + origin[2];
    deltaX = Math.abs(endX – startX);
    deltaY = Math.abs(endY – startY);
    deltaZ = Math.abs(endZ – startZ);

    end += (deltaX + deltaY + deltaZ)/gridRate + 3*holdTime;
    }

    p1 = strt + deltaX/gridRate;
    p2 = p1 + holdTime;
    p3 = p2 + deltaY/gridRate;
    p4 = p3 + holdTime;
    p5 = p4 + deltaZ/gridRate;

    if (time < p1){ ease(time,strt,p1,[startX,startY,startZ],[endX,startY,startZ]) }else if (time < p2){ [endX,startY,startZ] }else if (time < p3){ ease(time,p2,p3,[endX,startY,startZ],[endX,endY,startZ]) }else if (time < p4){ [endX,endY,startZ] }else if (time < p5){ ease(time,p4,p5,[endX,endY,startZ],[endX,endY,endZ]) }else{ [endX,endY,endZ] } Dan

  • Eric Sanderson

    October 6, 2008 at 8:33 pm

    That did the trick, so what happened there? Was it that in the previous code AE saw “start” as the beginning of the comp (frame 0)…and with the new one you just took the guess work out for AE and told it 0? And somewhere along the lines motion blurs sub frame sampling confused it.

  • Eric Sanderson

    October 6, 2008 at 8:37 pm

    uh oh, so i think i spoke too soon. Its weird because before i would get the error by just applying the blue to the cube…but i just got it again with the new code only saying theres no property or method for “deltaX”, and it only appeared after enabling the motion blur preview for the comp.

  • Dan Ebberts

    October 6, 2008 at 9:16 pm

    Interesting. Attempt #2:

    origin = [10,10,0]; //upper left hand corner of grid
    dimX = 8; //number of columns
    dimY = 6; //number of rows
    dimZ = 6; //number of planes
    gap = 20; // distance between cells (pixels)
    gridRate = 250; //speed (pixels per second)
    holdTime = .2; //(seconds)

    end = 0;
    j = 0;

    while (Math.max(time,0) >= end){
    seedRandom(j,true);
    startX = Math.floor(random(dimX))*gap + origin[0];
    startY = Math.floor(random(dimY))*gap + origin[1];
    startZ = Math.floor(random(dimZ))*gap + origin[2];
    j +=1;
    seedRandom(j,true)
    strt = end;
    endX = Math.floor(random(dimX))*gap + origin[0];
    endY = Math.floor(random(dimY))*gap + origin[1];
    endZ = Math.floor(random(dimZ))*gap + origin[2];
    deltaX = Math.abs(endX – startX);
    deltaY = Math.abs(endY – startY);
    deltaZ = Math.abs(endZ – startZ);

    end += (deltaX + deltaY + deltaZ)/gridRate + 3*holdTime;
    }

    p1 = strt + deltaX/gridRate;
    p2 = p1 + holdTime;
    p3 = p2 + deltaY/gridRate;
    p4 = p3 + holdTime;
    p5 = p4 + deltaZ/gridRate;

    if (time < p1){ ease(time,strt,p1,[startX,startY,startZ],[endX,startY,startZ]) }else if (time < p2){ [endX,startY,startZ] }else if (time < p3){ ease(time,p2,p3,[endX,startY,startZ],[endX,endY,startZ]) }else if (time < p4){ [endX,endY,startZ] }else if (time < p5){ ease(time,p4,p5,[endX,endY,startZ],[endX,endY,endZ]) }else{ [endX,endY,endZ] } Dan

  • Eric Sanderson

    October 6, 2008 at 9:55 pm

    the 2nd attempt was it. So what was the problem?

  • Dan Ebberts

    October 6, 2008 at 10:06 pm

    There are a bunch of variables that weren’t getting defined for times less than zero. I just changed the expression to treat times less than zero the same as zero.

    Dan

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