Implementing Vehicle rig in Unreal

Setting up a vehicle in Unreal was actually the first project I ever did in Unreal. The steps I am following here show the way I setup that project. The aim here is mainly on blueprints for steering wheel, RPM/speed needles and basic vehicle rig setup. This project is not meant to explore the process of creating advanced vehicle project,  it is rather the begining of once such project.

The project is heavily dependant on the Vehicle template in Unreal and uses the default pawn as well as the following Unreal Vehicle guide:

Rig setup

In the Physics Tab the whole hirarchy of coliders is selected and deleted. This is because the automatically generated colliders are usually not very good.

For this model 2 type of colliders will be created - one for the car body and four for the wheels. The wheel colliders must be the same size as their corresponding models.

It's important to change the Physics Type of the wheels colliders to Kinematic or they wont work properly.

 

Wheels

Two VehicleWheel blueprints are created - one bp that will support the front wheels and their rotation and one bp for the rear wheels. Check out Vehicle User Guide[1] for more info.

A handy tip is to use the console command PXVIS COLLISION In EventBegin node which is going to show where the collisions of the wheels are.

 

Animation Blueprint

To handle the animation of the car a VehicleAnimInstance with the rig of the corresponding car is created.  First and foremost a Mesh Space Ref pose node is created and then connected to Wheel Handler and then connected to Final Animation Pose.

Then in the Pawn/Mesh component, the animation blueprint is attached under Anim Class.

Animation Blueprint wheel handler
Animation Blueprint wheel handler
Result after attaching the animation blueprint to the vehicle
Result after attaching the animation blueprint to the vehicle

Steering Wheel

First a Transform (modify) Bone and a new float are created for the steering wheel's rotation in Animation BP. For the animation blueprint and its vars to be accessed outside a reference has to be created in the Event Graph. Next step would be creating a new function that will be called from EventTick update.The new function calculates the steer angle of the wheels and feeds it into the steering angle var. And voila steering wheel should be steering.

Animation BP
Animation BP
Creating reference in the Event Graph for the animation bp instance
Creating reference in the Event Graph for the animation bp instance
Update animation function called from Update event tick
Update animation function called from Update event tick

Speed and RPM Needles

Speed and RPM needles use the same priciple as the steering wheel in the animation blueprint.

Before adding the functionality for the speed needle we need to make sure we are talking in the same units in Unreal in the preference window.

Speed and RPM needles
Speed and RPM needles
Units
Units
Speed needle in Update animation function
Speed needle in Update animation function

Resources

Write a comment

Comments: 0