Vehicle User Guide

At the end of this guide, you'll have a fully functional vehicle that you can use in your own game projects.

Goal

In this guide, we'll cover the creation of a vehicle using the Wheeled Vehicle Blueprint class in a new blank project. This guide will take you through the process of creating all the necessary in-editor items you need to have a functional vehicle but assumes you have your own Skeletal Mesh and a Physics Asset ready to go. At the end of this guide, you should have a fully functional vehicle similar to the one from the Vehicle Game or the Vehicle Template.

If you need information on getting a vehicle Skeletal Mesh and a Physics Asset into the engine, please see the Vehicle Content Guide. Alternatively, you can work out of the Vehicle Template or the Vehicle Game project to have access to a pre-built Skeletal Mesh and Physics Asset. The Vehicle Template is in the New Project menu of the Unreal Project Browser, and the Vehicle Game is on the Learn tab of the Epic Games Launcher.

Objective

During the course of this tutorial you will create the key components that make up a Vehicle in Unreal Engine 4 (UE4). Some of this requires assets that you create outside of UE4, while the majority of the components will be created right inside of the Editor!

This is the individual assets that make up the Vehicle we'll construct:

  • A Skeletal Mesh

  • A Physics Asset

  • An Animation Blueprint

  • A Vehicle Blueprint

  • One or more Wheel Blueprints.

  • A TireConfig Data Asset

By the end of this guide you'll know how to setup each of these asset types and how they work together to bring your vehicles to life!

  • How to configure a TireConfig Data Asset

  • How to configure a Wheel Blueprint for your Font and Rear wheels.

  • How to setup an Animation Blueprint specifically for a Vehicle.

  • How to configure your Vehicle Blueprint with your Skeletal Mesh, Animation Blueprint, and Wheel Blueprint(s).

  • How to configure your Axis Mappings and Bindings to control your Vehicle.

  • How to create and assign a new Game Mode to spawn your vehicle.

1 - Required Project Setup

  1. Open Unreal Engine from the Launcher. The Project Browser will appear.
  2. Click on the New Project tab and then select the C++ tab. From there, select Basic Code so we have a clean starting point, and make sure With Starter Content is set. We'll need to enter a project name, so we'll use "QuickStart". We can now click Create Project and get started.

CreateProject.png

The Unreal Editor will now open our new project. Visual Studio will also open and load the solution file that our project has created.

BlankProject.png


2 - Creating a TireConfig Data Asset and Wheel Blueprint

In this first step to creating our own vehicle, we have two parts that go together to make up the wheels for the vehicle; the TireConfig Data Asset and the Wheel Blueprint class. We'll start by first creating the TireConfig Data Asset and then move on to create the Wheel Blueprint that houses properties for our wheels, including where the TireConfig data is assigned to.

Follow along with the steps below to get started creating your TireConfig data and then using that with a Wheel Blueprint.

Tire Config Data Asset

The TireConfig Data Asset is used to control Friction Scale. This value not only affects the raw friction of the wheel but also scales the values for how difficult (or easy) it is for the wheel to slide while in a hard turn. There is also the additional option of Tire Friction Scales, which enables you to specify a specific Friction Scale to different Physical Material types.

Create your TireConfig Data Asset

  1. In the Content Browser, click the Add New Button, then hover over Miscellaneous and then select Data Asset from the Context Menu.
  2. In the Pick Data Asset Class window, select TireConfg to create this type of Data Asset.
  3. The new asset will be created in your Content Browser. Make sure to give it a recognizable name so you can easily locate it later.
In the Pick Data Asset Class window, you may notice that there is also a TireType Data Asset class. This is a deprecated function and is only used when upgrading older projects to Unreal Engine, version 4.15 (or a later version). You should not have any reason to use this data asset type if using Unreal Engine, version 4.15 (or later).

Wheel Blueprints

In most cases, you will have at least two wheel types; a wheel that is affected by steering and one that is not. Also, this may be the case for having differently sized wheels for the front or the back, in which case, you have full control over setting the differing radii, mass, width, handbrake effect, suspension, and many other properties to give your vehicle the handling you desire.

Click the image for full size view.

Create your Wheel Blueprint

  1. In the Content Browser, click the Add New button, then select Blueprint Class from the menu.
  2. In the Pick Parent Class window, under All Classes, search for "wheel" and then select VehicleWheel.
  3. The new asset will be created in your Content Browser. Make sure to give it a recognizable name so that you can easily locate it later.
  4. Optional - Repeat these steps again so that you have a front and rear wheel type.

Editing the Wheel Blueprint

Now that you've got your Wheel Blueprint(s), open them in the Blueprint Editor, where you'll see all the available options to edit your wheels!

There are five properties that we need to initially change for each wheel, as the rest of them will change how the vehicle performs (and should be tweaked later) as you start to test out the vehicle in your own game.

  • Shape Radius
  • Shape Width
  • Affected by Handbrake (usually restricted to the rear wheels)
  • Steer Angle (usually only the front wheels)

The properties here are set to match the Buggy from Vehicle Game. If you're using your own Skeletal Mesh, you may need to use different values for the Shape Radius and Shape Width

Now, under the Tire section, you can assign the Tire Config Data Asset that you initially created using the Tire Config selection box.

End Result

At this point, you've set up your Tire Config Data Asset, which is used to control how much the tires slide on any surface, having set up the Wheel Blueprint that can be used to specify all of the different properties for your wheel. In the next step, you'll continue creating the assets you need, which make up our vehicle ,by creating the Animation Blueprint that handles all of the necessary animation information for our vehicle (such as spinning tires, steering, suspension, etc).

3 - Creating a Vehicle Animation Blueprint

At this point, you've created the TireConfig Data Asset and your Wheel Blueprint(s), which you'll use later with the Vehicle Blueprint. In this step, you'll continue to ready your content by creating an Animation Blueprint that drives all of your animation needs for the wheels on the vehicle.

Animation Blueprints

The Animation Blueprint will be used to control the animation of our Vehicle Skeletal Mesh so that it has animations specific to a vehicle, like spinning tires, suspension, handbrakes, and steering. To offload a lot of the work in creating animations for these types of things, you can use the Wheel Handler node to drive these types of animations.

Wheel Handler Node

Where the Animation Blueprint is used to get and control animations for the vehicle, more specifically, the Wheel Handler node makes controlling all of the animations for the vehicle fairly easy with little to no additional setup. It simply grabs the necessary information from the wheels (How fast is it spinning? Is it affected by the Handbrake? What are the suspension settings for this wheel?) and translates the query results to an animation on the bone that the wheel is associated with.

Creating the Animation Blueprint

  1. In the Content Browser, click the Add New button, then hover over Animation, selecting Animation Blueprint from the menu list.
  2. In the Create Animation Blueprint window, locate and select your Skeleton from your vehicle's list. Then click OK.
    Alternatively, you can create an Animation Blueprint directly from your Skeletal Mesh by selecting it in the Content Browser, where you'll be able to select Create > Anim Blueprint.
  3. Now that you've got an Animation Blueprint to work from, you can open it from the Content Browser by selecting and double-clicking it. From the main toolbar select Class Settings and then in the Details panel set the Parent Class to VehicleAnimInstance.
    If this is not properly set to the right Parent Class, you will not have access to nodes needed later in this guide.
  4. In the Anim Graph, you'll want to start by right-clicking to bring up the context menu and then searching for the Mesh Space Ref Pose node. Select it from the list to create it in place.
  5. Next, right-click in the Anim Graph to bring up the context menu and then search for the Wheel Handler, selecting it from the list to create it.
  6. Now, connect the nodes so that your Anim Graph looks like this one.
  7. Optionally, if you have additional struts or other suspension needs (like the Buggy from Vehicle Game) you will need additional nodes in your Animation Graph to handle the joints that affect those polygons. In the Buggy, from Vehicle Game, the extra joints are used to control the axle connections to the wheels. These are driven by a simple Look At node, which, when given the wheel joints, will be driven by the Wheel Handler node and the Look At nodes will make sure the suspension stays attached to the wheels.

End Result

You've finished setting up the Animation Blueprint! The Component to Local conversion node will be created automatically and the Animation Blueprint will now drive the wheels of the vehicle. Continue on to the next step to learn how to create a Vehicle Blueprint that brings all of the previous steps together.

4 - Creating a Vehicle Blueprint

By now, you've created a few different assets (TireConfig Data Assets, Wheel Blueprints, and an Animation Blueprint), which you need to bring together to create a fully functional vehicle in Unreal Engine 4 (UE4). In this step, you'll create the Vehicle Blueprint, using those assets that were previously created and set up.

Creating and Editing the Vehicle Blueprint

  1. In the Content Browser, click the Add New button, then select Blueprint Class from the menu.
  2. In the Pick Parent Class window, under All Classes, search for "wheel" and then select WheeledVehicle.
  3. In your Content Browser, the new Blueprint asset will be created. Make sure to give it a recognizable name so that you can easily locate it later.

  4. From the Content Browser, select and open your newly created Vehicle Blueprint.

  5. Click on the Skeletal Mesh Component named Mesh from the Components Window. Then, in its Details panel, set the Skeletal Mesh selection box to your vehicle's own Skeletal Mesh asset.

  6. Set the Anim Blueprint Generated Class to your vehicle's Animation Blueprint that we created in Step 2 of this guide.
  7. Go back to the Components window and select the Add Component button and select a Camera Component

  8. Use the Viewport in the Blueprint Editor to position the Camera where you would like it to be relative to your vehicle. In the image below, it is positioned behind, slightly raised, and tilted down towards the vehicle.

  9. With the Camera component still selected (in the Details panel under Camera Settings), disable the option for Use Pawn Control Rotation. This will lock the camera to its view direction (rather than that of the Player Controller).

  10. Next, select the Vehicle Movement Component in the Components window.

    In the Details panel under the Vehicle Setup section, expand the arrow next to Wheel Setups and for each wheel (0-3) set the following:
    • Set the Wheel Class to the Wheel Blueprint(s) you created.
    • Set the Bone Name to the name of the joint that should be controlled by the wheel.

      The Bone Name in the above image is specific to this skeletal mesh. If you're using the Vehicle from Vehicle Game, you can use these Bone Names.

The order you assign wheels has no bearing on if it is a front or a rear wheel, only the Bone Name and Wheel Class have any effect. For organizational purposes, it's best to keep the wheels (front and rear) together.

If you need more than 4 wheels, you can click the "+" icon next to the Wheel Setups property to add more.

End Result

At this point, assuming your vehicle is not substantially larger than a minivan, the default values will be a good starting point for you to move on to the next step in this guide, where you'll setup the inputs and controls to properly test the vehicle.

5 - Setting up and Testing Functionality

By now, you've done everything you need to do to have a fully functional vehicle by creating the Wheel, Animation, and Vehicle Blueprints in Unreal Engine 4, except to be able to control it in your game! In this step, we'll show you how to set up the necessary axis mappings and bindings so that you can drive the vehicle around and fully test its capabilities.

Because there are a few ways to go about setting up the vehicle for testing, and assuming that you started with a blank project template, all of the inputs will need to be added to control the vehicle. If you started with an existing template, some (or all) of these axis mappings and bindings may already be available for you in your project.

Setting Up The Controls

  1. Go to the Main Menu and select Edit > Project Settings to open the Project Settings window. Then, under the Enginesection in the side panel, select Input.
  2. In the Bindings menu, set up the following controls (if you do not currently have them listed). If you do have them listed, it would be wise to double-check that they are set up like the ones listed here, so that you know your vehicle will work correctly.
    1. First, we'll setup an Action Mappings by clicking the + sign next to the Action Mappings property.
    2. Rename the Action Mapping from "NewActionMapping_0" to Handbrake. Then, expand this property to use the selection box to change the key value from "None" to Space Bar.
    3. Next, we'll setup the Axis Mappings by clicking the + sign next to the Axis Mappings property. Repeat this so that you have two Axis Mappings, like this:
    4. Rename the first Axis Mapping from "NewAxisMapping_0" to Forward. Then do the same for the second and rename it from "NewAxisMapping_1" to Right.
    5. Expand the Forward Axis Mapping and then click the + sign once so that you have two Axis Mappings listed under "Forward". Then set the first "None" to use the W key for input. Set the second "None" to use the S key.
    6. Next to the S key input under the Forward Axis Mapping, change the Scale value to be -1.
    7. Expand the Right Axis Mapping and then click the + sign once so that you have two Axis Mappings listed under "Right". Then set the first "None" to use the D key for input. Set the second "None" to use the A key.
    8. Next to the A key input under the Right Axis Mapping, change the Scale value to be -1.


      Once you're done setting the Action and Axis Mappings, your Bindings should look like this:
  3. Now that you've got the controls set up, you'll need to actually do something with them. So, open up the Vehicle Blueprintthat you created and locate the Event Graph, where you'll be able to call these Axis and Action events that you created in the Project Settings Input section.
  4. In the Event Graph, for the throttle setup create the following:
  5. In the Event Graph, for steering setup the following:
  6. In the Event Graph, for the handbrake setup the following:

End Result

Now with these Input Events added you have a fully functional vehicle that can take input movement! In the next and final step, you'll set up a new Game Mode that uses your Vehicle pawn as the default pawn when you launch a game.

6 - Setting up a New Game Mode

In the previous step, you finished setting up our Vehicle Blueprint and assigned all of the controls that you need to make it work properly. In this last step, you'll finish by setting up a new Game Mode that uses your own Vehicle Blueprint as the Default Pawn for the game.

If you did not use a Blank Project Template when starting this guide you may find that you already have a Game Mode assigned that conflicts with the one you'll create in this step. Use the steps below to create a new Game Mode so that you can spawn in the vehicle you've created throughout this guide.

Creating a New Game Mode

  1. In the Content Browser, click the Add New button and select Blueprint Class from the menu list.
  2. In the Pick Parent Class window, select Game Mode Base, and then click the Select button to create the Game Mode Blueprint.
  3. In the Content Browser, double-click to open the new Game Mode Blueprint so that you can edit it. In the Details under Classes, next to Default Pawn Class, use the drop-down selection to choose Your Vehicle Blueprint (which you created in Step 3).

    Aftering doing this, you can click Save and then Close this window
  4. In the Main Viewport window, in the World Settings tab under the Game Mode section, set GameMode Override to Your Game Mode Blueprint.

End Result

Congratulations! Now, when you Play in Editor (PIE) you should automatically spawn in with your very own vehicle that you created. You've learned everything you need to create your own working vehicles in UE4. As you worked your way through this guide, you learned:

✓ How to configure a TireConfig Data Asset.
✓ How to configure a Wheel Blueprint for your Font and Rear wheels.
✓ How to setup an Animation Blueprint specifically for a Vehicle.
✓ How to configure your Vehicle Blueprint with your Skeletal Mesh, Animation Blueprint, and Wheel Blueprint(s).
✓ How to configure your Axis Mappings and Bindings to control your Vehicle.
✓ How to create and assign a new Game Mode to spawn your vehicle.

Doing More with Vehicles in Unreal Engine

For additional resources with Vehicles you can take a look at the following pages: