Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Problems with Auto-Orienting camera AND Auto-Orienting objects along path

  • Problems with Auto-Orienting camera AND Auto-Orienting objects along path

    Posted by Doug Olberman on May 1, 2013 at 12:31 am

    Hi, I’ve come up against two similar, possibly-related problems. I’m working on a comp where I’m trying to build a “roller coaster” effect. I’ve built a “railroad track” that the camera zooms around on, and there’s a “passenger” mounted on the camera, so the whole thing looks as if there were a go-pro mounted at the front of a roller coaster car, facing the rider. I don’t have the railroad track visible, but I do have a single layer repeated along the length of the track, on either side of the camera (so it’s like trees whizzing by the rider).

    The main problem I’m having is orienting the trees along the path. I’d like them to rotate on the x-axis when going up/down a hill and along the y-axis when going around a corner. I set them up by creating a 4-second motion path (ie the railroad track) with an slider named “offset” on it, then put this expression on my tree layer:
    start = 0;
    end = 4.0;

    track = thisComp.layer("Track Path");
    offset = (track.effect("offset")("Slider")/100)*(index-1);
    track.position.valueAtTime(offset);

    [big ups to Dan Ebberts for this workflow insight]

    I then repeated the tree layer as many times as I needed, and voila! The offset slider spaces them out along the path, no matter where I move it. But, they’re all standing straight up and always facing down the z-axis.

    Possibly relatedly, I’ve got camera orientation problems too. My camera has this Ebbertsian expression on its position:
    start = 0;
    end = 4;
    y = thisComp.layer("Track Path").effect("y control")("Slider");
    track = thisComp.layer("Track Path");
    travel = linear(track.effect("travel")("Slider")/100,start,end);
    track.position.valueAtTime(travel) + [0,y,0];

    It moves along the track perfectly, but again does not rotate on the x or y axes –and thus the 2.5D trees become heavily distorted at such sharp angles (the camera has 165° lens on it). Whenever I turn on Auto-Orient to Path, it works most of the time, but occasionally does a 180° flip for one frame. I’ve found other people on here who’ve encountered this exact problem, but I couldn’t find a working solution…

    Right now my stopgap is to set this as the Point of Interest:
    lookAhead=-.5;
    position.valueAtTime(time+lookAhead);

    …which seems to work, but I don’t know if it’s causing problems when trying to fix the trees.

    I’ve messed around with all iterations of Auto-Orientation for both the camera and the trees, and tried some expressions from this forum (of course including Mr. Ebberts’ Auto Orient on Y Only geniusness), but to no avail. Any ideas for either quandry? Thanks!

    Doug Olberman replied 13 years ago 1 Member · 1 Reply
  • 1 Reply
  • Doug Olberman

    May 1, 2013 at 7:06 pm

    Ah, of course, the answer was right in front of me all along. For auto-orienting the trees, I simplified Dan Ebberts’ auto-orienting expression from his Creating Trails page:

    strt = 0;
    end = 4.0;
    t = thisComp.layer("Track Path");
    offset = (t.effect("offset")("Slider")/100)*(index -1);
    vect = t.position.velocityAtTime(offset);
    lookAt(position, position - vect)

    And my stopgap solution for auto-orienting the camera works with it!

    But now I have a new problem about offsetting the flank paths which I’ve started a new thread about…

    Hope this helps someone down the line!

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