FORUMS: list search recent posts

# Linking counter to distance

FAQ   •   VIEW ALL
 Linking counter to distance on Sep 24, 2012 at 1:40:37 pm

Hello everyone, I'm making a stopping distance demonstration, I have the counter linked up to a null from cinema4d and as the car goes it counts up to the number following the x-position. The issue I'm running into is that we want the number to match when the car is at a certain distance(84.97ft, 104ft and 129.67ft). In the image you can see the cars are at about the same position but the numbers are off. In real life they would be at the same distance. In cinema I set up each car to start at 0 x-position and end at there given number in ft. I'm really stumped on this one. thanks for the help. Thanks to Dan for helping solve the first issue with this.

```x=thisComp.layer("Car 104").transform.position[0]; carStart = -30; carStop = 3169.9199; numStart = 0; numStop = 104.00; ease(x,carStart,carStop,numStart,numStop);```

 Re: Linking counter to distanceon Sep 24, 2012 at 3:22:27 pm

If they have the same expression, you should only get different results if the x positions aren't exactly the same. In your screenshot it looks like the top car is slightly ahead of the bottom car.

Dan

 Re: Linking counter to distanceon Sep 24, 2012 at 3:42:23 pm

It is slightly ahead but it's showing a 4ft difference which is way more than it should be. If there was a marker there for 55ft no mater how fast the car was traveling it would still hit that 55ft mark at that same point. Does it have something to do with the velocity of the car?

 Re: Linking counter to distanceon Sep 24, 2012 at 5:56:22 pm

Here's another example which I think explains it a little better. The bottom car should read around 83-85ft but is at 94ft. They are both around the same x-position when they are by the blue line. Does the speed of the car have something to do with the value increasing so fast?

```x=thisComp.layer("Car 104").transform.position[0]; carStart = -30; carStop = 3169.9199; numStart = 0; numStop = 104.00; ease(x,carStart,carStop,numStart,numStop);```

 Re: Linking counter to distanceon Sep 24, 2012 at 6:03:44 pm

If both expressions are exactly the same (except for the car layer name, of course) then the only variable is the x position. Speed doesn't factor into it.

Does one of the cars have its anchor point at a different location than the other?

Dan

 Re: Linking counter to distanceon Sep 24, 2012 at 6:13:05 pm

All anchor points are the same, I just copied the cars and adjusted the x-position. The nulls I set up in cinema are children to the car so they weren't animated.

 Re: Linking counter to distanceon Sep 24, 2012 at 6:18:42 pm

Hmmm... OK-just to be sure, post both expressions as well as the x positions that correspond to the last picture you posted.

Dan

 Re: Linking counter to distanceon Sep 24, 2012 at 6:33:10 pm

 Re: Linking counter to distanceon Sep 24, 2012 at 6:47:41 pm

Now I'm really confused. The carStop and numStop values are different in the two expressions. So I wouldn't expect the results to be the same. Also, since the ranges are different, the easing may be affecting how the numbers track (especially near the beginning and end of the range). Try switching to linear (at least until you figure out what's going on).

Dan

 Re: Linking counter to distanceon Sep 25, 2012 at 8:40:18 pm

Hey Dan,
I was messing around and this is almost getting what I need. It works until I add the third marker. So I'm kind of using the markers distance markers. Start=0 Half=100 and End=150. I can adjust the markers for each car. It just keeps giving me an error when I add that third marker.

```thisComp.layer("Null 9").transform.position[0]; Â m1 = marker.key("Start").time; Â Â m2 = marker.key("Half").time; m3= marker.key("End").time; Â Â linear(time, m1, m2, m3, 0, 100, 150);```

 Re: Linking counter to distanceon Sep 25, 2012 at 8:49:06 pm

linear() can't do more than one interplation, so you'd have to break that up into two pieces:

m1 = marker.key("Start").time;
m2 = marker.key("Half").time;
m3= marker.key("End").time;
if (time < m2)
linear(time, m1, m2, 0, 100)
else
linear(time, m2, m3, 100, 150);

Dan