Skip to content

Vehicle Movement

Michele edited this page May 9, 2023 · 4 revisions

Vehicle Movement configuration

Introduction

Once you have the assets of your vehicle you are ready to use it in the game. To do so you need a Pawn.

Let's take as example Blueprints/Vehicles/Sedan/SedanBP.uasset, that BP inherit from AReplayVehiclePawn which is ABaseVehiclePawn which is a AWheeledVehiclePawn. AReplayVehiclePawn and ABaseVehiclePawn are just C++ classes I made for my game to manage some extra stuff.

If you just want a very base and simple vehicle you could inherit directly from AWheeledVehiclePawn which is the Unreal class. This is already done for example in the Vehicle Template project by VehicleTemplate/Blueprints/SportsCar/SportsCar_Pawn.uasset, as that project is 100% BP.

Vehicle BP asset

Wheels

To manage some settings you need to create the wheels asset, which determine the mesh of the wheel, the radius, suspensions, and a lot of other parameters you can configure as you desire.

This is the example of the asset for the rear wheels of the sedan.

Vehicle Wheel example

Movement

The wheel asset is connected to the mesh bone name inside the Vehicle Movement Component of the Pawn.

Look at this example of AmbulanceBP.

Little example of Vehicle movement

The Vehicle Movement Component is the main component present inside the BP, added by AWheeledVehiclePawn which control the whole movement of the vehicle. It contains a tons of parameters and curves you can configure, such as: torque, steering, suspensions, braking and engine setup.

Center of mass

An important thing for a Vehicle is the center of mass. By default this is probably in the middle of the mesh, which is too high and will make the vehicle roll too easily. All of the Vehicles in the project override it.

It is possible to visualize it using p.Vehicle.ShowCOM 1 as explained in the Vehicle Debug Commands-

Input

The Vehicle Controller of my game is made in C++, but what it does it is exactly the same as the Vehicle Template, it read the input and sends it to the Vehicle Movement Component.

Extra

The vehicles in my game sometimes have some BP code to control the emissive materials of the brake lights.

This is inspired by the Vehicle Template project which does the same thing.

Vehicle Lights BP Code