I thought I would show you how easy it is to do this without an Armature and using only standard Animation Nodes to animate it. So, none of my own nodes and no scripted nodes, here is the car again:
The first thing to say is that as I have also taken out the Armature, I no longer have IK chains to steer the wheels by Ackermann principles, so we have to go elsewhere to do this. Here is the basic setup using the two planes as before on the other page, five empties and the wheels:
There are two empties at the back, both are parented to the fix plane, but one (track-steer) has a Damped Track Constraint to the highlighted one in the centre of the front wheels, which in turn is parented to the target plane.
The front wheels are parented to the two empties on the front axle, these are the steer pivot points for the front wheels. These empties are parented to the track-vehicle empty at the back axle, as are the rear wheels.
In order to make the wheels rotate we must use the same principles as before, i.e. base their rotation on the movement of the fix plane in X along its curve. Here is the node tree that drives the vehicle along, based on the current frame and also rotates the wheels:
The wheels belong to a group called wheels – I am very imaginative with my object group names as you can see. These objects are fed into a Loop Sub-programme so I only have to do the sums once and feed the results to each wheel.
I take the current frame and feed it into this expression; (x – 1) / 2 this uses the frame before the current, so the animation is at rest when the frame is 1, then divide this by 2 so the fix plane moves half a unit every frame. I then add 5 to this to move the target plane, just as I did on the previous version using Drivers. I then divide this value by 0.6 to rotate the wheels, again as before.
So, as you play the animation, the planes move around the curve and the wheels rotate, steering them is slightly more involved, here is the node tree:
So all this to avoid using an IK chain, is it worth it, probably not, but it was a good intellectual exercise. We first of all need to know the exact rotation of the two empties at the rear of the car, track-steer and track-vehicle – the difference between them will be used to steer the wheels. But there is a problem, if I use an Object Transforms Input node, I get the rotations of the objects – zero for both all the time, because they are parented to an object that thinks it is only moving in the X plane. So I use an Expression node with this in it:
What does this mean, well it give the precise transforms of the object in World Space, the  at the end gets the rotations, which are always Quaternions irrespective of what the rotation mode for the object is. This is then converted to Euler and fed into the next Expression node, which has the formula:
(abs(x) – abs(y) ) * z
So, abs( ) always return positive, whether the variable is negative, or not, x gets the Z rotation of the first object, y gets the Z rotation of the second object, I then subtract one from t’other and multiply by my “Steer Factor” 2.0 again as with the Driver version. there is a very good mathematical reason why it is 2 in both cases, but I am not going to explain it because it takes more effort than it is worth, just take my word for it.
This value is fed into another Expression node to remove the Glitches associated with Blender’s mathematical precision when working at, or around zero, again I won’t explain it, just accept that this formula below does the job:
(abs(x) > y) * x
Where y is my “Glitch Factor” set in this case at 0.03, so if the rotation is less that 0.03 Radians, the steering will not move, thus taking out the glitches. This value is then fed into the next two Expression nodes, one for each wheel, having the formulae:
((x > 0.01) * y) + ((x < -0.01) * y) + x
((x >= 0.01) * -y) +((x < -0.01) * -y) + x
Note the use of conditional expressions again. These are very similar, except one adds the Ackerman Factor, one subtracts it from the wheels’ vertical rotation. and parts like this: (x >= 0.01) return a boolean, so if x is greater than or equal to 0.01, True or 1 is returned, this is then multiplied by a number, the Ackerman Factor and 0.05 Radians in this case, to add, or subtract, a further angle from the wheels’ steering so they point to the centre of the curve correctly. The output of these nodes is used to rotate the empties and in turn, the wheels in the vertical axis. Herewith the proof:
The use of Number nodes to enter the various factors allows you to tweak this without having to touch the Expression nodes. That concludes the AN version of the Vehicle Tutorial – personally I would use a combination of the two, keeping the Armature and driving the animation with Animation Nodes rather than keyframes, but that is just a personal preference.
It is worth saying that all the complex stuff could be put into a script node to save having to remember it all, or having to copy/paste the nodes from one project to another, I might do that one day.
If you would like the blend file, just use the contact page to message me.
Here’s the video: