Skip to main content
russell888
Participating Frequently
January 27, 2016
Answered

motion path cars to follow leader (null object) and maintain a fixed distance

  • January 27, 2016
  • 2 replies
  • 369 views

I am trying to create a model of my local intersection where a car will ease to a stop at a red light and the chain of cars behind will follow and stop at a fixed distance behind the car in front.

I'm so close yet so far to the solution to this, I am still fairly new to expressions so I need a bit of help. I previously made a freeway with about a 1,000 cars by using a CG Snake tutorial by Jerzy Drozda Jr at maltaannon.com, but starting this next project I realized this method did not allow the cars to maintain a fixed distance.


I then read Dan Ebberts article "Creating Trails" of www.motionscript.com and found that Jerzy Drozda's method, while perfect for small projects, is problematic with a large amount of objects because it uses a "cascading" expression, where the expression in one layer refers to the previous layer which refers to the previous layer, etc. This can enormously increase the amount of work that After Effects has to do at each frame. I had first hand experience with this when I made my freeway. After Effects was nearly impossible to use because there was a 10 second lag after every click.


Which brings me to my current problem, getting this expression to work I have attached the file I am working on as a download link from my Google Drive here


Here is the original formula from motionscript.com - if you want to see his guide just search "//start time of template motion" in Google and click on this first link.


I have tried so many things with this expression but the dam car just refuses to follow the null object!


in Position property:

strt = 0; //start time of template motion

end = 4.0; //end time of template motion

t = thisComp.layer("template");

offset = (t.effect("offset")("Slider")/100)*(index -1);

travel = linear(t.effect("travel")("Slider")/100,strt,end);

t.position.valueAtTime(travel - offset)

in Orientation property:


strt = 0; //start time of template motion

end = 4.0; //end time of template motion

t = thisComp.layer("template");

offset = (t.effect("offset")("Slider")/100)*(index -1);

travel = linear(t.effect("travel")("Slider")/100,strt,end);

if (travel <= offset){

  vect = t.position.velocityAtTime(0);

}else{

  vect = t.position.velocityAtTime(travel - offset);

}

lookAt(position, position + vect)

This topic has been closed for replies.
Correct answer Lilybiri

Hmmm, are you sure this is in the correct forum? This is a Captivate forum, are you using Captivate to create this animation?

2 replies

russell888
Participating Frequently
January 27, 2016

yep not the correct forum, I wouldn't have known if you hadn't told me! First post on Adobe, wrong forum :/

Lilybiri
Legend
January 27, 2016

Did you find the correct forum? I could have moved your question, but was not sure to which forum.

Lilybiri
LilybiriCorrect answer
Legend
January 27, 2016

Hmmm, are you sure this is in the correct forum? This is a Captivate forum, are you using Captivate to create this animation?