DriveSim - Vehicle Physics
Plugin for Unreal Engine
DOCUMENTATION
Ensure DriveSim is enabled in plugins menu :
DriveSim Vehicle Physics is Plugin for Unreal Engine, written in C++ and fully exposed to Blueprints.
Perfect solution to build any kind of car games (racing, arcade, semi-realistic or exotic...)
DriveSim C++ classes :
ADriveSimVehicle (APawn)
UDriveSimWheelComponent (USceneComponent)
ADriveSimAIFollowSpline (AAIController)
ADriveSimVehicle :
This pawn class is used as the basis for creating, displaying the vehicle, manages physics updates, handling commands for interacting with the vehicle (throttle, steering, brake, handbrake, gear-up, gear-down), engine RPM, force calculation and gearbox management.
UDriveSimWheelComponent :
This scene component is used to manage each wheel of the vehicle. It is in charge of updating the wheel physics (suspension and damping, friction, steering forces...) and displaying the wheel as a static mesh with animations (spin rotation, position, steering rotation, skid marks and sounds)
ADriveSimAIFollowSpline :
This class manages AI controller to follow a spline on a map.
This AI Controller interact with ADriveSimVehicle to drive the car and adhust input commands (steering, throttle, brake...) according spline curves and vehicle speed.
Physics Sub-stepping
By using physics Sub-stepping you can get physics simulations that are more accurate and stable.
In Project settings, Physics, enable substepping et set Max Substep Delta Time to 1/120
Input
Configure your input to handle axis and action mapping for :
Throttle, Brake, Handbrake, Steering, GearUp, GearDown, Reset
Exemple for keyboard :
Create Chassis
Create a new Blueprint Class from parent DriveSimVehicle
Open the new Blueprint and set the static mesh for the vehicle
Important : The mesh should have a correct collider to interact with physics.
The collider plays an important role in determining collisions, but it also directly influences the mass and dynamics of the vehicle, and all the forces acting on it (acceleration, braking, cornering, etc.), as well as other elements such as its center of gravity, which affects suspension and overall driving behavior. Make sure your mesh has a collider that conforms to the visual representation of the mesh, or you can also play with a different collider shape to obtain a unique dynamic for your vehicle (e.g. a collider smaller than the mesh, or shifted or oriented on an axis to obtain a different dynamic).
The vehicle mesh doesn't need wheels becauses wheels will be added as individual components in the next step to handle physics per wheels. This allow to build any kind of regular or exotic vehicles with differents wheels shapes or behavior.
Create Wheels
To create the wheels you have several options. You can create a new blueprint class from the DriveSimWheel Component parent class and add it as component of the chassis, or add base DriveSimWheel Component directly into the vehicle blueprint. The advantage of a new blueprint class is that you can create wheel template and reuse them for other car models and create modularity.
For ease of use, we'll create wheels by just adding DriveSimWheel base components.
Add a static mesh for the wheel (or not if your car doesn't need wheels (Hovercraft...). Here the static mesh wheel doesn't affect physics, it is mainly used for the rendering as physics wheels are computed internally by the plugin. The only relevant aspect of the static mesh is the wheel radius that is computed from the static mesh bounding box that is used internally in suspension and wheels positions calculations.
Tip : In transform, you can change the scale the wheel.
Adjust the wheel placement in the editor an repeat process for others wheels.
Tip : Setup wheels settings and duplicate wheel components.
Setup Wheels
At this stage, it's important to set the correct parameters for each wheel. (Hence the advantage of a blueprint class to avoid repeating this step).
Override Wheel Radius: If you want a different radius from the mesh
Is Reversed : Apply a visual symetric transformation (if mesh is not symetric)
Affected by steering : Needed if the wheel can steer
Affected by engine: Needed if the wheel can drive torque from engine
Affected by steering : Needed if the wheel can steer
Affected by Brake: Needed if the wheel can brake
Affected by Handbrake: Needed if wheel can handbrake
Low Speed Friction : Tire grip at low speed
High Speed Friction : Tire grip at high speed
Animate Wheel : Animate the wheel rotations and steering
Add Skid Marks : To create skid marks (+sound)
Draw Debug : Show debug shape of suspension
Once all the wheels have been created and positioned, the vehicle is already functional, but all that remains is to assign the inputs to drive the vehicle.
Don't forget to add a spring arm and a camera or other components of your choice.
Configure Input in Event Graph
Exemple :
Once done, place your blueprint in the world, assign possession for player and go for a drive.
Coming soon
Coming soon