Modular physics vehicles for Unreal Engine: cars, karts, trucks, bikes, and hover vehicles.
Modular physics vehicles for Unreal Engine: cars, karts, trucks, bikes, and hover vehicles.
NsVehicles drives physics vehicles in Unreal Engine: cars, karts, trucks, bikes, and hover vehicles. One physics body moves the vehicle. Suspension components trace the ground and push the body up. Module components add the drive, brake, steering, and other forces. It is for gameplay programmers and designers who want a vehicle that they can tune in the Details panel.
NsVehicles is not a full tire model, and it is not a Chaos Vehicles replacement. The wheels are traces, not colliders. The drive force acts on the body, not on each wheel. There is no clutch.
AsyncTickPhysics module. It is part of this repository.NsVehicles folder into the Plugins folder of your project."NsVehicle" and "AsyncTickPhysics" to PublicDependencyModuleNames in the Build.cs file of your game module. ANsVehicle derives from AAsyncTickPawn.NsVehicle as the parent.NsVehicleSuspensionComponent components under the root, one above each wheel position.Get Controls, then Set Throttle Input, Set Brake Input, and Set Steering Input.The default Engine module uses the arcade powertrain, so the vehicle drives with no other setup. In C++:
#include "Modules/Control/NsVehicleControlsComponent.h"
#include "Vehicle/NsVehicle.h"
void AMyPlayerController::DriveForward(ANsVehicle* Vehicle, const float Input)
{
Vehicle->GetControls()->SetThrottleInput(Input);
}
| Module | Getter | What it does |
|---|---|---|
| Controls | GetControls |
Holds the driver input and sends it to the server |
| Engine | GetEngine |
Makes the torque and the RPM. Selects arcade or standard |
| Transmission | GetTransmission |
Owns the gears, the differential, and the automatic gearbox |
| Drivetrain | GetDrivetrain |
Removes power when the driven wheels slip |
| Brakes | GetBrakes |
Owns the brakes, the reverse drive, and the handbrake |
| Steering | GetSteering |
Limits the steering by speed and turns the steering wheels |
| BodyDynamics | GetBodyDynamics |
Adds the body pitch and the bike lean |
| Aerodynamics | GetAerodynamics |
Adds the air drag in the standard powertrain |
| AirControl | GetAirControl |
Turns the vehicle in the air |
| AntiGravity | GetAntiGravity |
Pulls the vehicle to the surface under it |
| IdleLock | GetIdleLock |
Holds the vehicle in place when it stops |
| Network | GetNetwork |
Replicates the vehicle state |
| Animation | GetAnimation |
Spins the wheels for the take recorder |
ANsVehicle – The vehicle pawn. It runs the physics step and calls the modules in a fixed order.UNsVehicleModuleComponent – The base class of every module.UNsVehicleSuspensionComponent – One wheel: the trace, the spring, the tire forces, the wheel mesh, and detach.UNsVehicleInteriorComponent – The base class of the interior parts.UNsVehicleArticulatedComponent – A mesh that moves on one axis from an input.UNsVehicleAI – Spline following with a PID steering output.GetControls()->SetThrottleInput / SetBrakeInput / SetSteeringInput – Drive the vehicle.GetControls()->ApplyHandbrakeInput – Pull the handbrake.GetControls()->SetExtReplicationInput – Send a custom value from -1 to 1 to the server, in slot 0 to 5.DetachWheel / ReattachWheel – Release a wheel with an impulse, and attach it again.Jump – Add an upward velocity change when the vehicle is on the ground.Event Async Tick runs two times in each physics step.