Tutorial-5 Bike 2

This tutorial shows how to rig the bike from this page, with suspension and a rider. Here is the video:

I have altered the rig to have IK chains for front and rear suspension, added a second tilt bone to pitch the bike forwards (braking) or backwards (wheely) in addition to the sideways lean of the bike. I have also added anchor points for the IK targets of Erkinator’s arms, so they stay on the handlebars as the bike steers. I parented Erkinator’s Armature to the bike’s pitch bone to keep him in place. Other movements of Erkinator are done with keyframes on his various bones.

I use my Speed & Acceleration node to get the correct pitching of the bike, based upon the acceleration, so also output these values to the text object parented to the camera. Positive acceleration causes the front of the bike to pitch up, negative acceleration (braking) causes the front of the bike to pitch down, more on this later. You may have noticed that his head is not in the correct position in the video, this is also dealt with later when we lean his head sideways correctly thus:

Here is the revised Armature, along with the usual fix and target planes, associated empties and the bike’s track curve, you will note that the bike-lean bone has been moved to the back, in line with the rear wheel, this is so the bike-pitch bone is centred on the rear wheel:

Here is a still image from the video, showing the front forks compressed and the back wheel off the ground, so the rear suspension is relaxed and the bike is pitched forward to raise the back wheel during heavy braking:

We will now take a look at the bones in the bike armature and list what is parented to what, has which constraints and Drivers, etc. Here is the back end of the bike:

  • Bone steer-track is parented to root, inherits scale and rotation and has a Damped Track constraint to the empty parented to the target plane.
  • Bone bike-lean is parented to root, inherits scale and rotation and has a Driver on it’s X axis var * -3.4 where var is the Z rotation of steer-track.
  • Bone bike-pitch is parented to bike-lean and inherits scale and rotation.
  • Bone swing-arm is parented to bike-lean and inherits scale and rotation.
  • Bone rear-stroke is parented to bike-lean and inherits scale and rotation. It has an IK constraint with rear-IK as the target and a stretch value of 1, chain length is 1.
  • Bone rear-IK is parented to swing-arm and inherits scale and rotation.
  • Bone rear-cyl is parented to rear-stroke and inherits rotation, NOT scale.
  • Bone rear-piston is parented to rear-stroke and inherits rotation, NOT scale.

So, bike-lean tilts the bike over in corners, bike-pitch pitches the bike forwards or backwards for wheelies/braking, swing-arm rotates the swinging arm and operated the rear shocker. The top of the rear shocker is bone parented to rear-cyl and the bottom is bone parented to rear-piston.

Here is the front end of the bike:

  • Bone steer-control is parented to root and inherits scale and rotation and has a Driver on its Z axis var * 1.5 where var is the Z rotation of steer-track.
  • Bone fork-top is parented to bike lean and inherits scale and rotation, it has a Driver on its Z axis var * 1.5 where var is the Z rotation of steer-track.
  • Bone fork-IK is parented to steer-control and inherits scale and rotation.
  • Bone fork-stroke is parented to fork-top and inherits scale and rotation, It has an IK constraint with fork-IK as the target and a stretch value of 1, chain length is 1.
  • Bone fork-low is parented to fork-stroke and inherits rotation, NOT scale.

So, if the bike is going around a corner, both steer-control and fork-top will rotate the same amount, this will pull fork-IK around as well. This action will compress the forks a small amount to keep the front wheel in the right place on the road. If the bike pitches forward or backward by tilting bike-pitch the front forks will be expanded or contracted, again keeping the front wheel where it belongs and the top of the forks where they belong. The top of the forks and handlebars, etc are bone parented to fork-top, the wheel, lower forks, mudguard, etc. are bone parented to fork-low.

Additionally two empties; hand-left and hand-right – these could also be bones, but this is just my way, are parented to fork-top and are used to keep the rider’s hands in the right place.

Controlling the rig:

It is up to you to decide how much you want to be automatic, based purely upon the steering, speed & acceleration of the bike and how much you want to keyframe as the bike travels along its route. So this section deals with all that, using keyframes and Animation Nodes. A picture to start with:

This bit of the AN node tree rotates the wheels as before on previous tutorials, simply by using the X movement of the fix plane and the radius of the wheels (0.8 and 0.9) respectively. Another picture:

This bit uses my Speed & Acceleration node to calculate the values based upon where the bike is on the current frame and the previous two frames – you need 3 locations to get two speeds to get one acceleration. You could do this by a Script or Expression node if you don’t have mine. Another picture:

This bit uses an Expression node to make the text for the text object parented to the camera showing speed and acceleration. The formula in the expression node is:

‘Speed: ‘ + str(int((x * 1.4))) + ‘0 Km/h Accel: ‘ + str(round(y,1)) +’g’

This just manipulates the various inputs to get a text output to feed the text object. Another picture:

This bit uses the current location and speed of the bike to calculate where I should keyframe it after so many frames at the current speed – this just saves me having to work it all out with a calculator all the time. Another picture:

This is the really clever automation bit, it can of course be omitted altogether and you could use keyframes instead, but it is all fed by the acceleration of the bike and uses my own Bone nodes to operate the various bones. If you don’t have my Bone nodes, you must use empties, etc instead and then use Copy Transform constraints for the various bones targeted to the empties controlled by Animation Nodes as here.

I make use of Math nodes to get the right amount of bike pitch, etc. for the given acceleration and then use Clamp nodes to control how much movement I will allow, so if the bike pitches beyond a certain value in braking, the bike will come off the floor, by raising the root bone, thus raising the rear wheel in the air whilst keeping the front wheel on the road. Similarly in acceleration, if the pitch goes beyond a certain value, the fork will stop expanding and the front wheel is raised off the road. The swing arm bone is also controlled to allow the rear suspension to expand or contract as the bike pitches.

Another picture of Erkinator accelerating:

He is lying flatter on the bike and the front wheel is lifted a little, he is also just getting his foot back on the footrest.

The important thing to remember in all this is that the bike wheels must be kept on the road, unless you want them to be off it for a valid reason, and the bike itself must be allowed to move, or rotate as in real life, then the suspension must take up the slack to a certain degree, then it will move the wheels off the road. The wheels must never be allowed to go into the road other than very small amounts that could be explained by tyre deformation under high downward load; you might even use a Lattice Modifier to deform the tyre properly here…

Finally, another consideration is to set the lean angle, not only based upon the steer angle, but also feed some speed component into it as well. If I take a certain radius bend at 30 mph then at 60 mph I will have to lean the bike further the faster I go, until I fall off of course! So I might add a speed component into the bike-lean angle driver to make it more realistic.

The Rider:

I ride a large motorcycle – a Honda CB750, so I know what should happen, he said with some reservations. One thing that bike riders do not do is allow their eye-line to go much beyond horizontal, so the height of your left eye above ground is never much different to the height of your right eye, otherwise you are extremely liable to motion sickness. also riders shift their weight around on the bike to ease cornering, acceleration and braking.

I have added a driver to his head bone, to keep the eye-line correct – the driver is this: var * 3.5 where var is the Z rotation of steer-track. I made it slightly less than the lean angle of the bike so his head is not perfectly horizontal, just close to it for realism.

So here he is on a corner, bike leant over and head not too much and his left knee stuck out a little:

So, we must try to do the same with our rider. The first thing I did was to parent the rider’s armature to the bike-pitch bone, so his backside stays where it should be, but of course I can still move his relative position by keyframing. Then I added Copy Location constraints to his arm IK Target bones so they follow the empties I described above, this keeps his hands on the handlebars when cornering. I can then keyframe movements of his back when braking/accelerating so he sits upright, or tries to lie flatter on the bike. I can also keyframe portions of his leg IK Target bones to put his feet on the road, or on the footrest.

I have also keyframed positions of the IK Pole Target bones so he puts his knees out when cornering, next I will also add some movement of his right wrist so he turns his hand to operate the throttle on the right handlebar – all the things that make the rider look more convincing.

Speed Influenced Leaning:

in order to make the lean of the bike speed dependant, the Driver for the bike-lean bone is altered to read:

var * -2 * var_s where var is the Z rotation of the steer-track bone and var_s is the Z height of a new Empty that is driven in it’s Z direction by the speed of the bike. This is done in Animation Nodes using an Object Transforms Output node fed by my Speed & Acceleration node. This reduces the lean from the steer component and adds in a lean based on the speed of the bike, so the faster it goes on any corner the more it leans, this formula makes sure the bike is upright if the speed is 0, as it should be.

Final thought:

These images will help to explain how this works, by keeping the wheels on the road and letting the body move and rotate, the suspension is activated accordingly:

At Rest.

Body Raised

Body Lowered

Body Pitched Forward

Body Pitched Backward

I cannot upload the blend file I used to do this on my site (WordPress won’t allow it), but it is HERE on the BlenderArtists thread.

This page is finished 😛