1. Import your car fbx with skeletal mesh ticked
· we are going to have 3 items:
· mesh (UE5Car)
· physics-asset (UE5Car-PhysicsAsset)
· skeleton (UE5Car_Skeleton)
* we’ll also have the materials which we should transfer to a new folder – Materials
· open the mesh, go to Asset Details and make sure that all the materials are correctly assigned
· next open the skeleton and make sure that the bone hierarchy is correct.
* an ideal hierarchy should be something like this:
· next open physics asset. if the physics bodies are not correct, delete them and recreate them.
* Remember to click on the settings-wheel and choose “Show All Bones”
2. Edit->Plugins and install ChaosVehiclesPlugin (a restart of UE5 may be required)
3. Create a Blueprints folder, and open it.
4. Right-click in the Blueprint folder,
· select [Blueprint Class],
· expand All Classes,
· search for WheeledVehiclePawn and
· Rename your Blueprint to a meaningful name (ie: CarBP) and open it. It will open in the Blueprint Editor.
· In the Components tab (left side) you will have three components:
Mesh (VehicleMesh) (Inherited)
Vehicle Movement Component (VehicleMovementComp) (Inherited)
· Click the Mesh to select it and from the Details tab at the right find the Mesh/Skeletal Mesh and select the UE5Car mesh.
Now from the Components tab:
· Click [Add] button and add a SpringArm under the Mesh,
and under the SpringArm Add a Camera
· Adjust the SpringArm’s position and rotation so the camera captures the Car at a good angle
· The SpringArm should not inherid the rotation of the controller, so with the SpringArm selected in the Components tab,
find the [Camera Settings] in the Details Tab, and uncheck all CheckBoxes under it.
· Also, turn off Camera collission: under the [Camera Collision] make the Probe Size: 0 and uncheck the [Do Collision Test]
· Select the Vehicle Movement Component
· From the [Details] Tab to the right, locate the [Wheel Setup] section
· and add 4 elements under the Wheel Setups by clicking the (+). Each element represents a wheel.
· Expand each wheel element and enter the Bone-Name for each wheel, in this sequence:
* You can find the BoneNames in the UE5Car_Skeleton
Next, we have the Engine Setup – under the [Mechanical Setup] section:
Notice the Max Torque value under the graph (the default is 300 which is fine)
· Open the Torque Curve Editor and create a curve from 0 to 300 by adding points to the graph by Shift+Click.
5. Right-click in the Blueprint folder,
select [Blueprint Class],
expand All Classes,
search for ChaosVehicleWheel and create.
* This Blueprint will contain all the settings for the the wheels, so it is basically our wheels profile/template.
* We need two Wheel Blueprints, one for the Front wheels and one for the Rear.
· Name the first one FrontWheel
· Duplicate it and name the other one RearWheel
· Open the FrontWheel Blueprint and in the Details Tab we are going to adjust its settings:
Under the Wheel section change the following:
· Axle Type: Front
· Check – Affected by Break
· Check – Affected by Engine (depending on your vehicle being AWD or FWD)
· Uncheck – Affected by Handbreak
· Check – Affected by Steering
· Change Max Steer Angle to 45
· Open the RearWheel Blueprint and in the Details Tab we are going to adjust its settings:
Under the Wheel section change the following:
· Axle Type: Rear
· Check – Affected by Break
· Check – Affected by Engine (depending on your vehicle being AWD or RWD)
· Check – Affected by Handbreak
· Uncheck – Affected by Steering
· After creating these objects, we need to add them into the CarBP Blueprint:
Open the CarBP Blueprint, select [Vehicle Movement Component], in the Details Tab locate the Wheel Setup section and expand it.
Expand each Wheel group and modify its [Wheel Class] accordingly:
· For the two Front Wheels, select [FrontWheel] from the drop-down menu.
· For the two Rear Wheels, select [RearWheel] from the drop-down menu.
· Next, Select the Mesh Component from the Components list, and from the Details Tab,
· Locate the Physics Section and make sure that the [Simulate Physics] is Checked
All Done! Our car is configured.
6. Now we need to create our Player Start:
Return to the main UE5 window and click the [Create] button (the white cube with the green [+], upper left),
expand Basic and choose [Player Start]
* This is where our player will be spawned
7. Right-click in the Blueprint folder, click BluePrint Class and
Click on [Game Mode Base] to create a new Blueprint and rename it to [CarGameMode]
· Open the Game Mode and from the Details Tab locate the Classes section,
and change the Default Pawn Class to [CarBP] object.
8. Open the World Settings (Window/World Settings)
· Change the GameMode Override into [CarGameMode]
· Also expand the [Selected GameMode] section and confirm that:
· Default Pawn Class is [CarBP]
9. Run the game to check that our car is spawned correctly.
* At this point, the suspension should be working as expected.
10. Stop the game
11. Open the [CarBP] Blueprint, switch to the Event Graph and click on the SpringArm to select it.
· Drag the SpringArm and drop it in the EventGraph
· Drag the SpringArm node and in the dropdown search for AddRelativeRotation and click it.
* This will help you change the rotation of your camera
· Right-click the Delta Rotation and click [Split Struct Pin] to split the vector into separate x,y,z values
· Ctrl+D to duplicate that, connect it with the SpringArm
· Now we need to add two mouse axes,
· Right-click in the EventGraph, search for mousex and select the · [Mouse X Event]
· Right-click in the EventGraph, search for mousey and select the · [Mouse Y Event]
· Connect the [Axis Value] of the [Mouse X Event] on the first Relative Rotation node [Delta Rotation Z(Yaw)]
* Any movement of the mouse on the X axis will affect the camera on the Z axis
* Connect the Exec node of the [Mouse X Event] on the [AddRelativeRotation] node as well!
· Connect the [Axis Value] of the [Mouse Y Event] on the second Relative Rotation node [Delta Rotation Y(Pitch)]
* Any movement of the mouse on the Y axis will affect the rotation of the camera on the Y axis
12. Test the game again, and you should see that you have a free rotating camera!
* Now notice that your car wheels:
1. they might touch the ground normally:
2. they might be above ground – like flying
3. or they might be inside the ground…
· if the wheels are flying or are inside the ground:
Open the Wheel classes [FrontWheel] and [RearWheel],
locate the [Wheel] Tab,
and increase or decrease the [Wheel Radius] accordingly until you manage to correct the wheels touching the ground.
13. Now let’s program the movement of the Car:
Open the [CarBP] Blueprint
Select the Vehicle Movement Component and drag it into the EventGraph window.
· Click and drag its node and from the drop-down search for [Set Throttle Input] and create It
· Click and drag its node again and from the drop-down search for [Set Brake Input] and create It
· Click and drag its node again and from the drop-down search for [Set Steering Input] and create it
· Click and drag its node again and from the drop-down search for [Set Handbrake Input] and create it
* These four nodes will control the movement of the vehicle.
14. Now we need to setup the axis mappings and the input mappings
· Go to Edit/Project Settings
· In the Input section there is an option for Action mappings and Axis mappings
· In the [Action Mappings] click (+) to add an action mapping and name it [Handbrake]
· Bind it to the Space Bar key
· In the [Axis Mappings] add (+) three new mappings:
1. first one will be Throttle. Bind it to the [W] key and make sure its scale is 1.0
2. second one will be Brake. Bind it to the [S] key and make sure its scale is 1.0
3. third one will be Steering. Bind it to the [A] key and set its scale to -1.0
· we also need to add another key under Steering and bind it to the [D] key and set its scale to 1.0
15. Open the CarBP Blueprint and connect the respective axis events into the respective inputs:
· Right-click in the EventGraph,
search for Throttle, Brake and Steering (under Axis Events) and create them
search for Handbrake (under the Action Events) and create It
* Now connect each event respectively
* For the Handbrake you need to duplicate the SetHandbrakeInput because we need one for On and one for Off.
Connect the first one to the InputAction Handbrake [Pressed] and the other one to the [Released]
16. Test the game again, and you should see that the car is moving and responding to the WSAD keys and Space as well.
* Notice that the wheels are static in this stage.
17. For the rotation of the wheels we need to create an Animation Blueprint:
· In the Content Browser, locate our car’s skeleton file [UE5Car_Skeleton],
right-click it, expand Create and select Anim Blueprint to create it.
· Name it [UE5Car_AnimBP]
· Open the [UE5Car_AnimBP], click on [Class Settings]
Locate the Parent Class under the [Class Options]
and change it into [Vehicle Animation Instance]
· Right-click in the AnimGraph window and search for [Wheel Controller for WheeledVehicle] and create It.
· Connect it into the [Output Pose]
· Right-click in the AnimGraph window and search for [Mesh Space Ref Pose] and create it.
· Connect it into the [Wheel Controller]
18. Now we need to link this Animation Blueprint in the [CarBP]
· Open the [CarBP], select the Mesh and under the Animation section
· Make sure that Animation mode is set to [Use Animation Blueprint]
· Set the Anim Class to [UE5Car_AnimBP_C]
19. Test the game again, and you should have rotating wheels too!
* You will notice that we have a blurring effect on the wheels while they rotate.
If you want to fix this:
Open Project Settings and search for [Motion Blur] and uncheck it.