The Setup in Unreal Engine 4
Now let us see how this demo has been set up inside Unreal Engine. Load up the project file in the editor to follow along, and open the vehicle's animation Blueprint. Note that most of the operations are applied four times, once for each wheel.
While driving the vehicle, the following things happen in the animation Blueprint:
First, the WheelHandler updates the position and rotation of the simulated wheels (
PhysWheel bones). The visible wheels (
VisWheel bones) then update their rotation by copying the rotation from the
The WheelHandler followed by Copy Rotation to the visible wheels.
This gives us a visually correct spin and steering, but the wheels will not change their position. That is handled separately in a later step.
Next, the lower arms (
ArmLower bones) aim at the position of the
PhysWheel. Arms on the right side of the vehicle use Y as the look at axis, while arms on the left side use Negative Y:
The ArmLower bones looking at the PhysWheel position.
The result of a LookAt node can easily be previewed in the 3D window of the animation Blueprint editor: the current target of a selected LookAt node is marked with a red cross. This is easier to see if you set the preview viewport to wireframe mode.
ArmLower bone rotates to match its LookAt target, it brings with it a child component called
POS_Hub. This is used in the next step to correctly position the Kingpin using a CopyBone node which grabs only the translation of the
Setting the Kingpin position.
The Hub and
VisWheel will later be set to the same position using the same method.
The next step adjusts the upper arms (
ArmUpper bones) by looking at their respective targets (
LAT_ArmUp bones) which have been placed in the correct position by the fact that these targets are children of the Kingpin bones, which were updated in the previous step:
Orienting the upper arms.
After setting the position of the hubs, there is some extra work that needs to be done on the front hubs only, to account for rotation around Z caused by steering. This is handled with LookAt nodes targeting
LAT_Hub bones that are children of the frontal PhysWheels:
Setting Hub position and steering angle.
Finally, after setting the VisWheel positions to match the
POS_Hub bones, we make sure that the upper part of the shock is aimed at the lower shockmount (
ShockMount_Low), and that the lower shock bone follows the position of that very same shockmount, which is a child of the upper arm:
Positioning visible wheels, and adjusting shock components.