Skip to main content

Vehicles

EDMountingVehicles is the Chaos bridge: everything that is true of a wheeled vehicle and of nothing else. It is a separate module so a project that mounts only horses and turrets never links a physics vehicle solver. Delete it from the .uplugin and the rest of the framework still builds — that is the test the split has to pass.

The easy way​

Derive from AEDMountableVehicle. It is an AWheeledVehiclePawn that already has:

  • a UEDMountableComponent,
  • a driver's seat tagged Mount.Role.Driver, parented to the vehicle mesh,
  • ApplyDriverInput wired to UChaosVehicleMovementComponent,
  • the handbrake pulled when the driver's seat empties.

A Blueprint deriving from it is a mesh, wheels and a torque curve — the same work as the engine's own vehicle template, and the mounting comes free. Add passenger seats by adding more UEDMountPointComponent; they register themselves, and the driver's seat has no special status beyond its role tag.

PropertyDefault
bStopWhenDriverlesstrueCut the throttle and pull the handbrake when the driver's seat empties.
DriverSeatSocketnoneSnap the driver's seat to a mesh socket at begin play, for meshes that carry one.

Why bStopWhenDriverless defaults on​

Chaos holds the last input it was given. A driver who gets out at speed otherwise leaves behind a car still at full throttle with the wheels turned, which drives itself into the nearest wall. Turn it off for the games where that is the intended stunt.

Two things it does for you that are easy to miss​

AEDMountableVehicle turns on physics simulation for the vehicle mesh, and tells Chaos not to require a possessing controller. A vehicle needs both, and neither is discoverable:

  • AWheeledVehiclePawn ships with bSimulatePhysics off. The engine's own vehicle template turns it on in the Blueprint, so a vehicle written in C++ inherits a car that cannot move.
  • Chaos throws away the input of an unpossessed pawn. Under the default possession policy the driver keeps their own controller, so the car has none — and every ApplyDriverInput is discarded a frame later. Turning the requirement off is right rather than a workaround: the question it exists to answer, may this input drive this vehicle, was already answered at the seat.

Either one alone gives a car that revs and does not move, with nothing in the log to say why. If you implement the interface on a vehicle of your own instead of deriving from AEDMountableVehicle, do both yourself.

The dashboard: what the driver asked for, and what the engine is doing​

A vehicle is watched by more than the person driving it. A steering wheel, a brake light, a rev counter and a HUD all want numbers that a spectator's machine does not have: the driver's keys reach the server and the driver's own client and nowhere else, and a spectator's copy of the car has a Chaos engine that nobody is driving — it idles while the real one is at the limiter. A rev counter that idles at a hundred and forty is worse than no rev counter.

So the base class replicates them, and every one of these is BlueprintPure and correct on every machine:

GetCommandedSteering()Steering, -1 to 1.
GetCommandedThrottle()Throttle, 0 to 1.
GetCommandedBrake()Brake, 0 to 1. The handbrake counts as a full one — a brake light does not know the difference.
IsHandbrakeHeld()
GetEngineRPM() / GetGear()From this machine's own Chaos where it simulates the vehicle, and from the server otherwise.
GetMaxRPM()The top of the range, never zero: it is the denominator of every rev counter.
GetSpeedKmh()Road speed, unsigned.
GetWheeledMovement()The movement component, already the wheeled kind — so a graph that asks about a tyre's slip is one node rather than three.

There is also one hook rather than a value:

  • GetDriverHandTargets(OutLeft, OutRight) — a BlueprintNativeEvent. Where the driver's hands go, in world space, for an animation to reach for. The default says there are none. Override it in C++ or in a Blueprint and point it at your steering wheel's grips; the example car returns two scene components on its column, and the driver's anim instance runs two-bone IK onto them.

The one ordering rule​

AEDMountableVehicle::Tick pushes the driver's input into Chaos before calling Super::Tick, and that is deliberate. A Blueprint's Tick event is dispatched from inside AActor::Tick — inside that Super call — so a Blueprint that trims the throttle for traction, or adds a yaw torque to catch a slide, runs after the push and its decision is the one that reaches the physics. Pushed the other way round, the raw input would overwrite the Blueprint's every frame: the car spins its wheels, never pulls away, and there is nothing in either graph to say why. A C++ subclass that overrides Tick calls Super::Tick first and is in the same position.

The other way​

You do not have to use that class. A vehicle that already derives from something else needs six things, four of them required:

// 1. In the class declaration, implement the interface.
class AMyVehicle : public AMyVehicleBase, public IEDMountableInterface { ... };

// 2. In the constructor, a mountable component and at least one seat.
Mountable = CreateDefaultSubobject<UEDMountableComponent>(TEXT("Mountable"));

DriverSeat = CreateDefaultSubobject<UEDMountPointComponent>(TEXT("DriverSeat"));
DriverSeat->SetupAttachment(GetMesh());
DriverSeat->RoleTag = EDMountingTags::Mount_Role_Driver;

// 3. Make the vehicle drivable at all — see above; both of these are required.
GetMesh()->SetSimulatePhysics(true);
GetVehicleMovementComponent()->SetRequiresControllerForInputs(false);

// 4. Steering, throttle and brake, forwarded from whoever is in the driver's seat.
// Where the car is simulated: the server, and the driver's own client, which predicts ahead of
// the server. A spectating client gets the call too, for its wheel and lights, and moves nothing.
void AMyVehicle::ApplyDriverInput_Implementation(APawn* Driver, const FVector2D& MoveInput,
float Throttle, float Brake, bool bHandbrake)
{
if (!HasAuthority() && !(Driver && Driver->IsLocallyControlled()))
{
return;
}
UChaosVehicleMovementComponent* Movement = GetVehicleMovementComponent();
Movement->SetSteeringInput(MoveInput.X);
Movement->SetThrottleInput(Throttle);
Movement->SetBrakeInput(Brake);
Movement->SetHandbrakeInput(bHandbrake);
}

// 5. Optional: stop when the driver leaves.
void AMyVehicle::OnRiderLeft_Implementation(APawn* Rider, FEDSeatHandle Seat) { ... }

// 6. Optional: doors, driven by anim notifies in the get-in montage.
void AMyVehicle::SetSeatDoorOpen_Implementation(FEDSeatHandle Seat, bool bOpen) { ... }

That is the whole integration. Steps 5 and 6 are optional; steps 1 to 4 are twenty-five lines.

Why throttle and brake are separate arguments​

A car needs both at once — a single signed axis cannot express braking while still rolling forward, which is what happens every time a player taps the brake at speed. Steering comes from MoveInput.X so one 2D axis binding drives the whole car.

Doors​

Mark a window in the get-in montage with UAnimNotifyState_EDMountEventWindow, tagged Mount.Event.DoorOpen and Mount.Event.DoorClose. The framework calls SetSeatDoorOpen on the vehicle at both ends of the window, on every machine, with nothing replicated — because every machine is playing the same montage. The door opens on the frame the animator decided the hand reaches it.

The seat handle is passed through, so a vehicle with four doors knows which one.

You do not need a montage for this. With no animation authored, the framework opens the door for the length of the transition and closes it at the end — see Animation. The example project's car is exactly this: four doors on hinges, driven entirely by the procedural transition.

Passengers who are not the driver​

Under the default KeepRider possession policy, a passenger keeps their own controller, their own camera and their own abilities while seated. ApplyDriveInput is a no-op for anyone whose seat is not tagged Mount.Role.Driver, so a passenger holding W moves nothing even if their input bindings are still live — you do not have to unbind anything when someone sits down.

For the driver's seat you can switch to PossessMount per seat, which is what the engine vehicle template does: the controller possesses the car and the character becomes scenery. Pick it when the vehicle pawn already owns its input, camera and HUD and you would rather not rewrite that.

How the car looks on somebody else's screen​

The driver's machine and the server run the vehicle's physics. Every other client shows a copy, and what carries that copy between updates is AEDMountableVehicle::PhysicsReplication.

The engine's Default mode sends transforms and snaps the copy onto each one as it arrives. That is fine for a crate and visible on a car, because the updates come in slower than the frame rate. Measured on this plugin's own demo, driving the truck in a straight line for two hundred frames:

serversecond client
body height, min to max23.6 – 24.3 cm26.3 – 38.6 cm
vertical swing0.6 cm12.3 cm
frames the copy did not move at all—17 of 199

The server saw a car steady to within half a centimetre; the client saw one hopping twelve. It reads as a physics bug and it is not one — it is the copy standing still and then catching up.

EPhysicsReplicationMode::PredictiveInterpolation fixes that by carrying the copy on its own velocity between updates, and it is the right mode for a vehicle only the server simulates, which is what a mount is: the driver's input arrives as an RPC either way, so there is no local prediction to lose.

It is not the default here, and the reason is worth knowing before you turn it on. It needs Project Settings → Physics → Tick Physics Async, and with async physics enabled the Chaos vehicles in this engine version do not move at all — full throttle, engine running, nothing. Turn both on together and test your own vehicles, or leave both off. Setting the mode without the project setting is the worst of the three: the copies then never move at all, and end a straight run twenty metres behind the server.

// In a derived vehicle, once your project has async physics on and you have checked it drives.
PhysicsReplication = EPhysicsReplicationMode::PredictiveInterpolation;

Aircraft, boats, anything else​

Nothing in EDMountingCore assumes wheels. ApplyDriverInput gives you a 2D axis, a throttle, a brake and a boolean; what they mean is your movement component's business. The example project's turret uses the same hook to aim a gun.