FORUMS: list search recent posts

Wheel Rotation On/Off Controller

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jaan Koppe
Wheel Rotation On/Off Controller
on Aug 19, 2014 at 8:38:07 am

Hi. I am creating a "2D Car Rig" to easily animate different part of the car.

Having trouble with the Wheels rotation. I have the wheels rotating when the Car is Moving on the x axis. I want that the rotation stops when a checkbox is enabled.

It works but the wheels are going to rotation value 0, when the checkbox is enabled.

My question is that how can I define the last position and stay to it while the chekcbox is enabled and continue on from that point when the checkbox is disabled ?

Thanks!

Jaan Koppe

if (comp("Main").layer("CarControl").effect("Break On")("Checkbox") == 0)
comp("Main").layer("Truck").transform.position[0]
else
0


Return to posts index

Dan Ebberts
Re: Wheel Rotation On/Off Controller
on Aug 19, 2014 at 10:26:59 pm

I think the expression you need is a little more complicated than you might guess. Your expression needs to calculate the cumulative value up to the current frame. That is, it will need to look at the checkbox keyframes in the past and calculate the effect that "on" frames in the past have on wheel's current value. The details depend on the nature of the your animation, but it can be done.

Dan



Return to posts index

Jaan Koppe
Re: Wheel Rotation On/Off Controller
on Aug 20, 2014 at 6:07:28 am

Thanks for the Reply Dan!

For now I have an animation like this:

http://reels.creativecow.net/film/car-wheel-rotation-test

Both wheel rotations are driven by the Car's x value.
And when the "Brake On" Checkbox is checked, then the First Wheel rotation value is simply 0.

So i am trying to give the first wheel a constant rotation value which is the current value of rotation. And when the "Brake On" is unchecked, then the Wheel Rotation follow's the car position x again.

Jaan


Return to posts index


Dan Ebberts
Re: Wheel Rotation On/Off Controller
on Aug 20, 2014 at 5:43:52 pm

What's the expression you're using now?

Dan



Return to posts index

Jaan Koppe
Re: Wheel Rotation On/Off Controller
on Aug 21, 2014 at 4:40:28 am

This is the first tyre Rotation expression:

if (comp("Main").layer("CarControl").effect("Break On")("Checkbox") == 0)
comp("Main").layer("Truck").transform.position[0]
else
0


Return to posts index

Dan Ebberts
Re: Wheel Rotation On/Off Controller
on Aug 21, 2014 at 6:55:06 am

I'm surprised that works (as far as matching the tire rotation to the truck's position). But since it does, you might be looking for something like this:


cb = comp("Main").layer("CarControl").effect("Break On")("Checkbox");
if (cb.value == 0){
comp("Main").layer("Truck").transform.position[0];
}else{
t = cb.nearestKey(time).time;
comp("Main").layer("Truck").transform.position.valueAtTime(t)[0];
}


Note that I have not tested this at all, so there are likely some problems with it, but hopefully it will be helpful.

Dan



Return to posts index


Dan Ebberts
Re: Wheel Rotation On/Off Controller
on Aug 21, 2014 at 7:15:58 am

Sorry--I think I messed that up. It will probably be more like this (but it's probably still not quite right):


cb = comp("Main").layer("CarControl").effect("Break On")("Checkbox");
if (cb.value == 0){
comp("Main").layer("Truck").transform.position[0];
}else{
n = cb.nearestKey(time).index;
if (time < cb.key(n).time) n--;
t = cb.key(n).time;
comp("Main").layer("Truck").transform.position.valueAtTime(t)[0];
}



Dan



Return to posts index

Jaan Koppe
Re: Wheel Rotation On/Off Controller
on Aug 22, 2014 at 7:19:37 am

Thanks for the code Dan!

The breaking part works very good, until the brake will be "released", then the wheel rotation value goes back to the car's position value.

I think, that now I need to track the car's position to get the current x value and apply that when the checkbox is unchecked?

I added a few lines to the code, got no error's but also no result:

need to use some other approach I think :)

tx = comp("Main").layer("Truck").transform.position;
n2 = tx.nearestKey(time).index;
if (time &lt; tx.key(n2).time) n2--;
t2 = tx.key(n2).time;

cb = comp("Main").layer("CarControl").effect("Break On")("Checkbox");
if (cb.value == 0){
tx.valueAtTime(t2)[0];
}else{
n = cb.nearestKey(time).index;
if (time &lt; cb.key(n).time) n--;
t = cb.key(n).time;
comp("Main").layer("Truck").transform.position.valueAtTime(t)[0];
}


Return to posts index

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