CARLA provides a general skeleton for 4-wheeled vehicles that must be used by all of them. The position and orientation of the bones can be changed, but adding new bones or changing he hierarchy will lead to errors.
__1. Download the skeleton__ `General4WheeledVehicleSkeleton` from [LINK].
<br>
__2. Import the skeleton__ into the 3D project of the new vehicle. This could be in Maya, Blender or whichever software used for modelling.
<br>
__3. Bind the bones__ to the corresponding bone.
* Bind each wheel to the bone named as `???`. Make sure to center the bone inside the wheel.
* Bind the rest of the mesh to the bone `VehicleBase`.
!!! Warning
Do not add new bones, change their names or the hierarchy.
__4. Export the result__. Select all the meshes and the base of the skeleton and export as `.fbx`.
*__2. Import the `.fbx`__ in its folder. The Skelletal Mesh will appear along with two new files, `<vehicle_name>_PhysicsAssets` and `<vehicle_name>_Skeleton`.
*__2.1 - *Import Content Type*__ — `Geometry and Skinning Weights`.
*__4.3 - Rename the blueprint__ — `BP_<vehicle_name>_anim`.
*__4.4 - Copy an existing Animation Blueprint__ — Go to `Content/Carla/Static/Vehicle` and choose any vehicle folder. Open its Animation Blueprint and copy the content.
*__4.5 - Compile the Animation Blueprint__ — Connect the content in the blueprint and click the button `Compile` on the top left corner.
*__6. Create blueprints for the wheels__. Inside the folder, right-click and go to `Created advanced assets/Blueprints class`. Create two blueprints derived from `VehicleWheel`, one named `<vehicle_name>_FrontWheel` and the other `<vehicle_name>_RearWheel`.
*__6.1 - *Shape radius*__ — Exactly the radius, not diameter, of the wheel mesh.
*__6.2 - *Rig Config*__ — `CommonTireConfig`.
*__6.3 - On the front wheel__ — Uncheck `Affected by Handbrake`.
*__6.4 - On the rear wheel__ — Set `Steer Angle` to `0`.
Adding 2 wheeled vehicles is similar to adding a 4 wheeled one but due to the complexity of the
animation you'll need to set up aditional bones to guide the driver's animation:
As with the 4 wheeled vehicles, orient the model towards positive "x" and every bone axis towards
positive x and with the z axis facing upwards.
```yaml
Bone Setup:
- Bike_Rig: # The origin point of the mesh. Place it in the point 0 of the scenecomment
- BikeBody: # The model's body centre.
- Pedals: # If the vehicle is a bike bind the pedalier to this bone, will rotate with the bike acceleration.
- RightPedal: # Sets the driver's feet position and rotates with the pedalier if the vehicle is a bike.
- LeftPedal: # ^
- RearWheel: # Rear Wheel of the vehicle
- Handler: # Rotates with the frontal wheel of the vehicle bind the vehicle handler to it.
- HandlerMidBone: # Positioned over the front wheel bone to orient the handler with the wheel
- HandlerRight: # Sets the position of the driver's hand, no need to bind it to anything.
- HandlerLeft: # ^
- Frontwheel: # Frontal wheel of the vehicle.
- RightHelperRotator: # This four additional bones are here for an obsolete system of making the bike stable by using aditional invisible wheels
- RightHelprWheel: # ^
- LeftHelperRotator: # ^
- LeftHelperWheel: # ^
- Seat: # Sets the position of the drivers hip bone. No need to bind it to anything but place it carefully.
```
__1.__ Import fbx as Skelletal Mesh to its own folder inside `Content/Carla/Static/Vehicles/2Wheeled`. When importing select "General2WheeledVehicleSkeleton" as skelleton A Physics asset should be automatically created and linked.
__2.__ Tune the Physics asset. Delete the automatically created ones and add boxes to the `BikeBody` bone trying to match the shape as possible, make sure generate hit events is enabled.
Add a sphere for each wheel and set their "Physics Type" to "Kinematic".
__4.__ Inside that folder create two blueprint classes derived from "VehicleWheel" class. Call them `<vehicle-model>_FrontWheel` and `<vehicle-model>_RearWheel`. Set their "Shape Radius" to exactly match the mesh wheel radius (careful, radius not diameter). Set their "Tire Config" to "CommonTireConfig". On the front wheel uncheck "Affected by Handbrake" and on the rear wheel set "Steer Angle" to zero.
__5.__ Inside the same folder create a blueprint class derived from `Base2WheeledVehicle` call it `<vehicle-model>`. Open it for edit and select component "Mesh", setup the "Skeletal Mesh"
and the "Anim Class" to the corresponding ones. Then select the VehicleBounds component and set the size to cover vehicle's area as seen from above.
__6.__ Select component "VehicleMovement", under "Vehicle Setup" expand "Wheel Setups", setup each wheel.
*__0:__ Wheel Class=`<vehicle-model>_FrontWheel`, Bone Name=`FrontWheel`
*__1:__ Wheel Class=`<vehicle-model>_FrontWheel`, Bone Name=`FrontWheel`
*__2:__ Wheel Class=`<vehicle-model>_RearWheel`, Bone Name=`RearWheel`
*__3:__ Wheel Class=`<vehicle-model>_RearWheel`, Bone Name=`RearWheel`
(You'll notice that we are basically placing two wheels in each bone. The vehicle class unreal provides does not support vehicles with wheel numbers different from 4 so we had to make it believe the vehicle has 4 wheels)
__7.__ Select the variable "is bike" and tick it if your model is a bike. This will activate the
pedalier rotation. Leave unmarked if you are setting up a motorbike.
__8.__ Find the variable back Rotation and set it as it fit better select the component SkeletalMesh
(The driver) and move it along x axis until its in the seat position.
__9.__ Test it, go to CarlaGameMode blueprint and change "Default Pawn Class" to the newly