Setup Drivable Vigilante Chaos Vehicle for UE5 - jgoffeney/Cesium4Unreal GitHub Wiki

Back

Description

Notes from the YouTube video from LeafBranchGames. It takes a military vehicle by Vigilante, converts it to UE5 and makes it player drivable.

References

Notes

Importing Vigilante Vehicles to UE5

Vigilante has a series of detailed military vehicles in the Unreal Marketplace which support UE 4.26-4.27. The first step is to add the vehicle to a supported UE4 project (using the ThirdParty template will automatically provide movement controls the project Input settings). I used the West_MRAP_Oshkosh like the video. Then just launch UE5 and select the UE4 project you created. Open it as a copy when prompted and the content will be converted to UE5.

This may not be necessary as you can import UE4 assets directly into UE5 if you disable the version checking. But I have not confirmed this.

Setting Up the Chaos Vehicle

Migration

If you want to migrate the completed vehicle to another project I recommend putting all the vehicle components in their own directory.

Enable Plugin

  • Enable the ChaosVehiclesPlugin which handle vehicle integration with the Chaos Physics system.

Create Blueprint

  • Create a new Blueprint based on class WheeledVehiclePawn to represent the vehicle (BP_Oshkosh).
    • The original vehicle Blueprint does not inherit from Pawn so the player can not possess it. It also contains extra elements that would have to be updated.

Add Skeletal Mesh

  • Open the Blueprint
    • Add the Skeletal Mesh
      • Select the Mesh component and then under Mesh->Skeletal Mesh select the existing Skeletal Mesh for the Vigilante vehicle.
      • Set Physics->Simulate Physics to true

InitialBlueprint

Add Throttle and Steering

  • Open the Event Graph
  • Add Steering
    • Setup the Steering blueprint as shown below.
    • The Set Steering Input node automatically handles left and right.
  • Add Throttle and Braking
    • Setup the Throttle and Brake blueprint as shown below (this was taken from the Unreal buggy vehicle).
    • The Set Throttle Input node only handles forward motion so the Set Brake Input is set up with it. A positive value enables the throttle and disables the brake while a negative value does the reverse. Also the Set Brake Input does require a positive value so if the event value is negative the brakes are applied and then the event value is negated to make it positive.

SteeringAndThrottle

Add Skeletal Animation

  • In the Content Brower find the Skeletal Mesh that you selected earlier for the vehicle blueprint and right click and select Create->Animation Blueprint.
  • Name and open the Blueprint

CreateAnimationBlueprint

  • Select from the main menu File->Reparent Blueprint and select VehicleAnimationInstance.

CreateAnimationBlueprint

  • Setup the Animation Graph
    • Under the Blueprint AnimGraph add:
      • Mesh Space Ref Pose
      • From the Component Pose output drag and add a Wheel Controller For Wheeled Vehicle node.
      • Select the output node to the Result input of the Output Pose node.

AnimGraph

  • Back in the main vehicle blueprint go to the Mesh component and Animation->Anim Class and select the animation blueprint we just created.

SetAnimClass

Add Third Person Camera

  • This provides the third person view then controlling the vehicle.
  • Return to the BP_Oshkosh Blueprint.
  • Select the Mesh component and add a Spring Arm component.
    • Set the Camera->Target Arm Length to 800
    • Set the Camera->Target Offset->Z to 300.0
  • Select the SpringArm component add a Camera component.

SpringArmAndCamera

Add Wheels

  • The wheels are the components that actually do the physics work and drag the rest of the skeleton along.
  • Within the BP_Oshkosh Blueprint select the Vehicle Movement Component.
  • Under Wheel Setup->Wheel Setups add an array element for each wheel on the vehicle.

WheelSetup

  • Create Wheel Blueprints.
    • The first two wheels are for the front as left and right and the next two are for the back.
    • Each WheelClass is ChaosVehicleWheel by default but we want to make front and back blueprints.
    • Press the '+' next to the WheelClass for the first wheel and it will create a new blueprint and you will save it (BP_OshkoshWheelFront).
      • In the blueprint editor set the Axis Type to Front.
      • Set Wheel->Wheel Radius to 65.0 and Wheel->Wheel Width to 40. (This depends on your actual vehicle model).
      • Set _Wheels Setup->Affected by Steering _ to true to turn with the "steering wheel".
      • Adjusting other setup values is done to try to create the feel of the vehicle you are modeling.
    • Repeat for the third wheel to make a rear wheel blueprint (BP_OshkoshWheelRear).
      • In the blueprint editor set the Axis Type to Rear and the same wheel dimensions as Front.
      • To make this a rear wheel drive vehicle set Wheel->Affected by Handbrake and Wheel->Affected by Engine to true.
      • Set _Wheels Setup->Affected by Steering _ to false.
    • Set the second and fourth wheels to use the front and rear blueprints, respectively.
Front Wheel Rear Wheel
MRAP_Front_Wheel MRAP_Rear_Wheel
  • Set Bones
    • Each wheel under Wheel Setup->Wheel Setups has a field Bone Name that needs to match its bone within the skeletal mesh.
    • Open the skeletal mesh editor (SK_West_MRAP_Oshkosh) and the wheel bones are named like lf_front_wheel_jnt and rt_rear_wheel_jnt where lf is left and rt is right. The use of front or rear should be obvious.
    • Return to the vehicle blueprint's Vehicle Movement Component and fill in the Bone Name fields in the order of left/right front and left/right rear.
Skeleton Bones Full Wheel Setup
SkeletonWheels WheelSetupFull

Setup Torque Graph

  • The torque graph provides the information for the physics system to react with the terrain at a given throttle RPM.
  • For the vehicle blueprint's Vehicle Movement Component go to Engine Setup->Torque Curve->External Curve and press Create External Curve to make a new curve. Save it under a useful name.

CreateTorqueCurve

  • Double click on the External Curve to open the editor.
  • Use the scroll wheel to zoom out (use Alt-Shift-RMB to change a single axis). The X axis is RPM and the Y axis is torque scaled.
  • Starting at 0 right click on the line and select Add Key. This adds a vertex to the curve you can move up and down. For a simple curve add keys at torque values around 0, 1800, 3600, 4500 and 5400. Drag the keys along torque so the max is about 1 for 3600 RPM with 0 and 5400 remaining at 0. Use the others to make a kind of asymmetrical parabola.

TorqueCurve

  • In the vehicle blueprint the value for Max Torque is multiplied by the graph value. This allows you to adjust the overall vehicle torque without readjusting the curve.
  • Under Engine Setup are several fields to further refine the feel of the engine.

Setup Physics Asset

  • In the Vigilante Content is a physics asset (PHYS_West_MRAP_Oshkosh). Double click to open editor.

  • First we remove all the current physics bodies. Then from the gear pulldown select Show All Bones.

  • Select the root bone.

    • Under the Tools tab select the Primitive Type as Box which will create a general representation of the vehicle body.
    • Set Auto Orient to Bone to false.
    • Press Add Bodies.
    • The created body will initially be very small so scale and position it to over the vehicle body.
  • Control select the wheel bones (same ones used to set up wheels).

    • Set the Primitive Type to Sphere.
    • Set Auto Orient to Bone to true.
    • Press Add Bodies.
    • These should fit to the wheels fairly well.
      • Set Collision->Collsion Response to false to keep them from colliding and bouncing off the world.
      • Set Physics->Physics Type to Kinematic to use the attached bones like suspension.

Migrating

To migrate the content you can select the folder containing the vehicle blueprint and Unreal will find the associated assets to copy to a different project. It will additionally copy the VigilanteContent folder with the assets used by the vehicle.

It is possible to copy the VigilanteContent assets to the your own folder and then assign them in the meshes and materials, etc. But when I missed something which results the animation / physics not working correctly. The tires don't turn and the vehicle slides around.

Troubleshooting

  • Vehicle immediately tips over on start
    • I when adding the left wheels to the VehicleMovementComponent I misnamed the bone like lt_front_wheel_jnt instead of lf_front_wheel_jnt. Therefore there wasn't a physics component to hold the vehicle up on the left side so it just fell over on startup.
    • The log had an error with LogAnimation: Warning: FBoneReference::Initialize BoneIndex for Bone lt_front_wheel_jnt