Vehicle Setup Guide
A template version of this tutorial is available here. It is still recommended to follow the tutorial if this is your first time setting up a vehicle, in order to understand the workings of the plugin.
A Static Mesh or Skeletal Mesh for the chassis and wheels of a vehicle
Static Meshes will need a separate wheel mesh
Skeletal Meshes should be setup for or similar to Unreal's WheeledVehicle system
Own the S47 Vehicle System Plugin
A basic understanding of Unreal Engine, some steps in this tutorial will expect you to know how to create or set up things without guidance
Step 1: Configure your Inputs
Before we can setup the vehicle, we need to know what our inputs are. So head into your Project Settings > Input and set up something similar to this image.
Step 2: Create the Base Vehicle
A. Create a new blueprint and choose the class “AVS_Vehicle” as the parent class. I normally name this blueprint “ProjectName_Vehicle” as it will include any code or components you want to share across all of your vehicles.
B. Open your new vehicle blueprint and add a SpringArm and attach a camera to it. We won't be setting up any inputs to move the camera so I’d recommend rotating the SpringArm to the side slightly so you’ll be able to see the wheels when you drive it.
C. Open the Event Graph. The vehicle is not running and in park by default, so for the tutorial vehicle we want to start the engine and move the shifter to drive.
Note: As of AVS 1.2 there is a new config option for vehicles to spawn with their engines running.
D. Also in the event graph, setup your vehicle to use the inputs you made in Step 1
Step 3: Create your Vehicle
A. Right click on your base vehicle blueprint and select “Create Child Blueprint Class”, this will be your actual vehicle so you can name it accordingly. For the tutorial I will name mine “Car”.
B. Open your new vehicle blueprint, then select the VehicleMesh component from the list and set it to your desired mesh
C. Add the component called “Vehicle Wheel” for each wheel that you need. Then move the component to the correct location, naming the components according to their respective location on the vehicle can also help productivity later on.
Step 4: Configure your Vehicle
A. Select ClassName(self) in the components list or press the “Class Defaults” button, you will notice in the details panel there are 4 categories Prefixed “Vehicle -”. These are where you configure values related to the vehicle as a whole. For now we just want to edit the transmission values, so open “Vehicle - Transmission”.
B. In the “Gears” section you will see there are 2 gears by default. Gear 0 will always be the reverse gear, and then everything after is a forward gear. Add 2 more gears, then configure them like the following image.
C. Now you’ll want to configure your wheel components. Select one of your wheels, in the details panel open the Wheel Config section. You can then select your desired wheel mesh if you have one. If no mesh is selected, it will use a sphere collision at the specified wheel radius size. If you do select a mesh, the collision will instead be that of the static mesh you select, so make sure your mesh collision is the shape you intend (a simple sphere is recommended). The following image is setup for a rear wheel drive vehicle. Note: if you have rotated the wheel components to have your wheel mesh face the opposite direction you may need to check the invert torque option.
Step 5: Setup the config assist HUD
The plugin includes a basic HUD to assist in the creation of vehicles. This step is not required but is recommended if you are not extremely familiar with Unreal Engine.
A. Create both a player controller blueprint and a game mode blueprint.
B. Open the new player controller, drag off the execution pin on Event Begin Play. Then type “Create Widget” in the box, and press Enter. Set the new Create widget node to the VehicleSetup HUD. Then grab the return value and use it to create the “Add to Viewport” Node. Lastly set the owning player to Self.
Note: You may have to check “Show Plugin Content” in the view options to find the VehicleSetup_HUD
If you need multiplayer, add a check to see if we are on the local controller.
C. Now open the main Unreal tab (the one with your loaded level), and click the blueprints button. You need to set your gamemode to the one you created, and then set your PlayerController within that game mode.
Step 6: Test what you have so far
If you have successfully followed along, you should now be able to drive your vehicle. Either set the default pawn in your gamemode to your vehicle, or place one in your level and set “Auto Possess Player 0” in the details panel. Once you are in the game, you can use ‘Page Up’ and ‘Page Down’ to move the shifter, you will see it change on the HUD. If you want to use the buttons and sliders, press ‘SHIFT + F1’ to bring your mouse cursor up. You can also use the HUD to play with different values for your springs. The springs values will apply for every wheel, overriding whatever you had set before.
Step 7: Setup your Skeletal Mesh
For this tutorial I am using the Buggy mesh from the Epic Games Vehicle Game project which you can find here: https://www.unrealengine.com/marketplace/en-US/learn/vehicle-game
Whatever Skeletal Mesh you have needs to have the Chassis of the vehicle as the root bone, and 1 bone for each animated wheel. Those are the only requirements.
A. The first thing that needs to be done is to setup the physics asset for your mesh. Open the existing one or create a new one to work with. Then clear everything in the skeleton tree so we are working with a blank asset.
B. Now create the collision for your vehicle chassis. If you don’t know how to do this you might want to look up some tutorials on setting up a physics asset, as it’s outside the scope of this one. I’m going to use a multi convex hull on my vehicle, since this is just a tutorial vehicle and doesn't need to be extremely accurate. Make sure you do not create constraints!
C. Now add some type of collision to each wheel bone. You do not need to set these shapes up as they are not used for collision.
D. We now need to setup our Collision mesh, this is going to be a separate static mesh that is going to act as the collision for the vehicle. The reason this needs to be done because our skeletal mesh is only cosmetic and does not contribute to the physics of the vehicle. Copy any static mesh to the directory you are keeping your Skeletal Mesh, and name it something like SM_Buggy_Collision. I usually use the Basic Cube mesh that you can spawn in the level editor.
E. In your PhysicsAsset, select the collision body for your Chassis, then in the details panel go to Body Setup > Primitives and copy the whole Primitives section.
F. Then in your Collision Asset, go to Collision > Primitives and paste them. You should now be able to see the Vehicle collision on your Collision mesh, if not click the collision button in the toolbar make sure “Simple Collision” is checked.
Step 8: Add Skeletal Mesh to Vehicle
A. Open your vehicle’s blueprint, set the VehicleMesh component to the collision mesh you created.
B. Add a SkeletalMeshComponent that attaches to the VehicleMesh and set it to your vehicle’s Skeletal Mesh. Then attach any wheels that will be animating a bone to your new skeletal mesh component.
C. Under Rendering for the VehicleMesh, you can set it to never be visible, or be hidden in game only.
D. Now select your wheel components, and clear the static mesh in the wheel config if it is using one (This is assuming you want to use the default sphere collisions, you can use a static mesh for collisions if you wish). Check the box “Connect to Bone” and type in the associated bone name. If you typed the bone’s name correctly, the component will snap to the correct location. Adjust the Wheel radius to match your wheel size (if you are using the default sphere collision). The rotation however will not snap, so make sure you have the X axis facing in the forward direction, Z axis facing in the upward direction, and the Y axis facing towards the side of the wheel that faces away from the vehicle.
Step 9: Drive your Vehicle
You should now be able to test your vehicle. From here you should have an idea of how the system works, play around with the settings to make whatever you want!