Advanced Car Rig - let's not wait for Andrew!

Everything Element 3D belongs here

Advanced Car Rig - let's not wait for Andrew!

Postby MBelinkie on 09/26/2013, 7:29 am

In his Simple Car Rig tutorial, Andrew said that a more advanced lesson was coming. But I've got a client who needs an animated car this week, so let's figure out how to build a better mousetrap. Seems to me we want to automate 4 things:

1. SPINNING WHEELS RIGGED TO MOTION OF CAR. I tried adding an expression linked to the wheels z rotation:
thisComp.layer("Car Null").transform.position[0]

Basically, when the car null moves 360 pixels, the wheels rotate 360 degrees. You could add a multiplier to increase the rate. BUT what happens when the car is moving in a curved path over x-space and z-space? A better expression would link rotation to SPEED that the Car Null is moving.

2. CAR FACES IN DIRECTION OF MOTION. This should be easy. Just orient the master car null towards motion.

3. WHEELS ROTATE ON Y-AXIS TOWARDS THE DIRECTION OF MOTION. Okay, this is tricky. I think this rotation should be linked to the rate of rotation of the master car null, which is in turn linked to direction. So if the master car null is rotating 10 degrees a second, the wheels rotate a little. If the master null is rotating 20 degrees a second, the wheels rotate further. When the master null isn't rotating at all, the wheels point straight forward.

4. CHASSIS MOTION. I suspect this might be impossible to automate, or at least it would require a tremendous amount of scripting. In the Simple Car Rig tutorial, we saw Andrew make the car body shift forward as the car braked, and then bounce a little upon stopping. Could this be automated? Maybe you COULD make the body tilt a tiny bit based on the acceleration or deceleration of the master null. Is there an expression for rate of acceleration? (Different than the rate of SPEED we need to make the wheels turn.) But I doubt you can automate that bounciness on the stop.

OPTIONAL 5. SOME SORT OF SWITCH FOR "REVERSE". I probably don't need this, but it would be cool! A reverse switch would basically reverse the orient in the direction of motion thing, so the back end of the car now points "forward." It also reverses the direction the wheels turn. And (as long as we're brainstorming) the switch also turns on red brakelight flares!

Anything I'm forgetting? I'm hoping some expression ninja can take a crack at this. Obviously it could all be done manually, but I prefer to automate anything I can to save time in the future. Thanks guys!
MBelinkie
 
Posts: 17
Joined: 07/23/2009, 11:18 pm

Re: Advanced Car Rig - let's not wait for Andrew!

Postby Maxweel on 09/26/2013, 8:20 am

Searching the forum would have spared you that long post! Although I agree it's a bit hidden and it's already pretty old, that was even before VC's announcement.

http://www.videocopilot.net/forum/viewtopic.php?f=42&t=95884#p345239

The suspension thing would be overkill though: from what I'd tried the expressions would either be too slow or give not-so-realistic results. So it won't do magic, you'll still have to keyframe stuff for realistic motion, but at least you don't have to worry about stuff like the wheels, orientation, etc

Mike Roberts did some really nice stuff with that, but with a lot of keyframing obviously (no mistery there):



All the body, bounces and cool stuff were keyframes, the rig was only used for the base of the animation, so don't expect magic.
Maxweel
 
Posts: 704
Joined: 03/12/2012, 8:21 am
Location: Ipswich, UK

Re: Advanced Car Rig - let's not wait for Andrew!

Postby MBelinkie on 09/26/2013, 8:27 am

I did search the forums but I must of missed this. And ironically, that originally post was from ME, last year. I just never saw that guy's project file because it was posted months later. Thanks for pointing it out. I'm going to try it out tonight.

That Mike Roberts project is gorgeous work.
MBelinkie
 
Posts: 17
Joined: 07/23/2009, 11:18 pm

Re: Advanced Car Rig - let's not wait for Andrew!

Postby Maxweel on 09/26/2013, 8:29 am

Haha :lol: ... I didn't even see it was you, and if you look at the first project I put there I actually replied the same day! But yeah, I uploaded the second project way after.
Maxweel
 
Posts: 704
Joined: 03/12/2012, 8:21 am
Location: Ipswich, UK

Re: Advanced Car Rig - let's not wait for Andrew!

Postby Maxweel on 09/26/2013, 8:32 am

Oh and yes, you should have a look at Mike's stuff, it's pretty neat. this was one of his first tries with the project and I remember he was just using the rig, some extra keyframes on the rotations, then Ease & Wizz.

Maxweel
 
Posts: 704
Joined: 03/12/2012, 8:21 am
Location: Ipswich, UK

Re: Advanced Car Rig - let's not wait for Andrew!

Postby klaus brandenburg on 09/26/2013, 8:38 am

Since y'all sorted it out already the only thing left to say is that I like the topics title.
too many clowns - not enough circuses
klaus brandenburg
 
Posts: 1733
Joined: 07/11/2012, 4:51 pm
Location: Munich / Germany

Re: Advanced Car Rig - let's not wait for Andrew!

Postby MBelinkie on 09/26/2013, 10:59 am

I just watched the demo for Ease & Wizz, and it looks really cool! Can't wait to get home and try some of this stuff.

I wonder if auto skid marks could be added to the rig? I'm imagining an emitter on each tire, leaving a line of black everywhere the wheels go. HOWEVER, the opacity of the emitter is usually 0, so it's not leaving any mark at all. It only gets turned up when deceleration goes above a certain point. In other words, the same conditions that cause the car body to tilt forward cause the tires to leave black streaks.

What do you think? More trouble than it's worth?
MBelinkie
 
Posts: 17
Joined: 07/23/2009, 11:18 pm

Re: Advanced Car Rig - let's not wait for Andrew!

Postby Maxweel on 09/26/2013, 11:13 am

To get a nice results you'd just have to use an expression that looks at the speed of the body and the rotation of the wheels around Y, but that will have to be to your taste ... but you'll probably want to keyframe the results anyway. So it might be easier to just do it manually, I don't know.

Assuming you want to do that with say Particular (since this way you can also get it to emit dust at the same time), just parent lights to the car body just under each wheel, then link all the Light Intensities to the same slider. You'll just have keyframe that slider to get the right skid marks when you want them.
Maxweel
 
Posts: 704
Joined: 03/12/2012, 8:21 am
Location: Ipswich, UK

Re: Advanced Car Rig - let's not wait for Andrew!

Postby MBelinkie on 09/27/2013, 7:05 am

First of all, thanks so much for posting that car rig project. It was really educational. I've spent a couple hours trying to understand how it works, and I have a couple questions that maybe you pros can help me with. I also think it's useful to have the actual expressions on the web, so let's go through it step by step and figure out how the rig works. NOTE: I took out the expressions that Maxwheel used to have control over the car's shape and size, because I want to keep it simple.

EXPRESSIONS THAT CONTROL CAR ORIENTATION
Layer Car Controller - Calc: Offset XZ
var tmp = position-position.valueAtTime(time-thisComp.frameDuration);
[tmp[0], tmp[2]]

How much the layer moved in the X and Z directions over the last frame.

Layer Car Controller - Y Rotation
tmp = effect("Calc: Offset XZ")(1);
180-radiansToDegrees(Math.atan2(tmp[1], tmp[0]))

This one confuses me a little (it's been a long time since Trig) but I believe this does the same thing as "Orient Along Path". It's using the Offset XZ expression to rotate the car. However, I believe it suffers the same problem as "Orient Along Path," which is that when the object stops it sometimes gets very confused about where it should be facing. Is there a way to overcome this?

EXPRESSIONS THAT CONTROL CHASSIS ROCKING
Layer Car Controller - Body: Suspensions
This is a slider that controls how dramatically we want the body to move.

Layer Car Controller - Calc: Turning Speed (I renamed it from your rig - used to be Orientation but I found this clearer)
thisComp.layer("Car Controller").rotationY.speed
This expression is exactly why we didn't "Orient Along Path" for the Car Controller layer. That would have faced the car in the right direction, but that turning would NOT have been reflected in the Y rotation. We need that value here. This expression is a measure of how fast the car is turning - a high value means a tight turn.

Layer Body Null - X Rotation
value + thisComp.layer("Car Controller").effect("Calc: Orientation")(1)*thisComp.layer("Car Controller").effect("Body: Suspensions")(1)/1000
This is your side to side rocking when the car is turning. It's a product of how fast the car turns, and how big your "Body: Suspensions" slider is.

Layer Body Null - Z Rotation
value + thisComp.layer("Car Controller").position.speed*thisComp.layer("Car Controller").effect("Body: Suspensions")(1)/40000
This is your front to back rocking. HOWEVER, I'm not sure this is right. It's based on speed, but it's really ACCELERATION that is important here. If the speed is constant, the car should actually be level. If the car is SLOWING DOWN, then the body should rotate forward. So don't we need an expression that calculates acceleration and tilts the car accordingly?

Also, any easy way to get the tiny bounce when the car stops? Applying something like Ease & Whiz to the Car Controller may not work, because if the car shifts backwards even a tiny bit the orientation will whip around. Right?

EXPRESSION THAT CONTROL WHEEL MOVEMENT
I did this a little differently than you. In your rig, you actually separate the front two wheels on different Element layers. Following Andrew, I put my front wheels on Element Group 2, and used multi-object to get them to rotate separately.

Layer Car Controller - Wheels: Steering
This is a slider that controls how dramatically we want to see the wheels rotate.

Element Front Wheels Group, Y Rotation Multi
thisComp.layer("Car Controller").effect("Wheels: Steering")(1)*thisComp.layer("Car Controller").effect("Calc: Turning Speed")(1)/100
This multiplies our "Calc: Turning Speed" with our "Wheels: Steering" to get the amount of left-right rotation we want our wheels to have.

Element Front Wheels Group, Z Rotation Multi
effect("Element")("3. Z Rotation Multi")
Links front wheel rotation to back wheel rotation.

Layer Car Controller - Calc: Distance
var step = thisComp.frameDuration;
var d = 0;
var tmp;
for (var i=0; i<time; i+=step)
{
tmp = position.valueAtTime(i)-position.valueAtTime(i+step);
d += length(tmp);
}
d

This calculates the distance the car has traveled since frame 1. And it doesn't just calculate the distance between start point and current point - it actually figures out the length of the path, even if it's curved. It is really cool!

Layer Car Controller - Wheel: Extra Rotation
A slider to offset the tire rotation. Not actually sure how useful this is, unless I'm missing something?

Element Back Wheels Group, Z Rotation Multi
thisComp.layer("Car Controller").effect("Wheel: Extra Rotation")(1)-radiansToDegrees(thisComp.layer("Car Controller").effect("Calc: Distance")(1)/100)
This actually rotates the wheels, based on the distance the car has traveled.

So open questions:
1. Any way to fix the problem where the orientation gets confused when the car stops? I'm going to have my car start and stop a LOT.
2. The expression that controls forward-backward movement of chassis seems questionable to me, since it should be based on acceleration and not speed.
3. Is there an easy way to get an automatic bounce effect when the car fully stops?

Once again, thanks so much for sharing your expertise!
MBelinkie
 
Posts: 17
Joined: 07/23/2009, 11:18 pm

Re: Advanced Car Rig - let's not wait for Andrew!

Postby Maxweel on 09/27/2013, 11:13 am

Remember I did that for myself, not as a finished product or something, so it's not like it's been thought over and over.

Layer Car Controller - Y Rotation

I believe this does the same thing as "Orient Along Path"

You answered this yourself I think, I don't remember all the reasons but in both projects I started with auto-orient and ended up calculating the pan myself.

I believe it suffers the same problem as "Orient Along Path," which is that when the object stops it sometimes gets very confused about where it should be facing. Is there a way to overcome this?

Re-read the description of the project in the other thread, I talked about that. The reason the car faces the wrong when stopped is that the orientation is calculated from the movement, so no movement = no orientation.

A way to sort this out can be to add a tiny movement of the car: instead of stopping completely, move it by a couple pixels over the whole duration during which the car should be stopped and see if that preserves the orientation well enough.

If you need to use a value that makes the tiny movement too noticeable just say the guy forgot his handbrake. Otherwise just add 2 keyframes between when the car stops and when it starts again.

EXPRESSIONS THAT CONTROL CHASSIS ROCKING

This expression is exactly why we didn't "Orient Along Path" for the Car Controller layer

"We"? ;)

Layer Body Null - Z Rotation

It's based on speed, but it's really ACCELERATION that is important here.

How do you calculate acceleration? You subtract 2 consecutive speeds. but you can;t do that in AE because speed doesn't have valueAtTime
So the only way to do that is to use 3 values of the position, which means using 2 valueAtTime in the expressions. Using valueAtTime on spatial properties too many times is the best way to make AE crazy, and I almost became crazy myself trying to do that once: the expression would simply give crazy results, with values jumping all over the place.
So I figured: well I'm going to use keyframes to correct the animation anyway, so let's use the speed as base of the animation, bake the values and add keyframes and expressions on top of that.

EXPRESSION THAT CONTROL WHEEL MOVEMENT

I did this a little differently than you. In your rig, you actually separate the front two wheels

Two wheels will not rotate the same way because in a curve, the wheel that's outside the curve will travel a longer distance than the one inside, hence it will rotate faster at some point. So I started by separating the wheels but I think I decided it did't matter at some point and just used the same rotation, I don't really remember what I did.


If we knew each other better you'd know I'm all for expressions, but in this case we're reaching strong limitations of AE because it's all based on 3D properties. Even the rotation of the wheels will sometimes get stuck between 2 frames, and you could even end up with static wheels when you export the sequence because the expression engine will get mad at some point.
So I don't really recommend trying to automate the whole thing, it just won't render as you think it will.
Maxweel
 
Posts: 704
Joined: 03/12/2012, 8:21 am
Location: Ipswich, UK

Re: Advanced Car Rig - let's not wait for Andrew!

Postby MBelinkie on 09/29/2013, 12:01 pm

I think there's a lot of wisdom in the idea that just because something CAN be driven by expressions doesn't mean that it will save time to do so. I did a bunch of different shots of the car, and in most of them I ended up removing an expression from my rig and manually keyframing, because the expression was acting a little glitchy and it was easier to do it myself.

Never the less, I'm pretty happy with the way the rig came out. It's a good starting point for building animations. In this test video, only the position of the car is keyframed. The orientation, chassis movement, and wheel rotation are all driven by expressions.
https://vimeo.com/75707955

Thanks for the help!
MBelinkie
 
Posts: 17
Joined: 07/23/2009, 11:18 pm

Re: Advanced Car Rig - Expression Help

Postby molgat on 11/26/2017, 4:57 am

Hi to everyone,

I am trying to move the car in y axis, as if it is driving/climbing on a slope / hill.

I tried to adapt the "x-z step" function to "y-z step effect but ı am constantly getting "index out of range" error as seen in the attached file..

I spend almost 6 hours on it, I am a beginner in expresions.

Your kind support is highly appreciated,

Best,

Tolga / Turkey
Attachments
Shot 2017-11-26 14;53;58.png
molgat
 
Posts: 5
Joined: 10/12/2017, 1:34 am
System Specs: i7 6400 k - gtx 1080


Return to Element 3D