# Getting started: a multiplayer car in your game in 15 minutes 1. Copy `Drivecraft` into your project's `Plugins` folder and open the project. Enable it in Edit > Plugins if it is not. 2. Make a Blueprint of `DRCVehicle` (right click in the Content Browser > Blueprint Class > All Classes > DRCVehicle). 3. In it, add your car's meshes under **Visual** (not under Body). Visual is drawn between simulation frames and slides over corrections; meshes on Body would show every step. 4. On **VehicleMovement > Setup**, set **Body Extent** to half your car's size, and the **Wheels**: one entry per wheel, its **Offset** at the top of the suspension, which wheels steer, drive and lock with the handbrake. The default setup is a 4.5 m family car (the example's); the ready-made setups are a good start for the rest (see [Tuning](#tuning)). 5. On the vehicle, set **Input Mapping** and the actions (**Throttle**, **Steering**, **Brake**, **Handbrake**, **Exit**). Throttle and Brake are axes from 0 to 1, Steering from -1 to 1. 6. Place it in the level, or spawn it on the server. 7. To drive it from a character: add **DRCRider** to your character (any class) and call **Try Enter Nearest Vehicle** from your interact key. See [Getting in and out](getting-in-and-out.html). 8. Play with two players (Play as Listen Server, or Client with a dedicated server). Try `Net PktLag=150` in the console. That is all the network setup there is. The vehicle replicates itself; do not turn on Replicate Movement on it. ## Lights and cameras The vehicle keeps the state of its lights, the same on every machine; drawing them is up to your meshes and materials. | Call | What it gives | |---|---| | Set Headlights, Set Indicator (Off, Left, Right, Hazard) | The driver (or the server) sets them; they show at once there and replicate | | Are Headlights On, Get Indicator | The state | | Is Indicator Lit (Right Side) | Whether that side's signal is lit right now: it blinks at **Indicator Blink Rate** on the server's clock, so every machine blinks together | | Is Brake Light On, Is Reversing | From the drawn input and the speed | | On Lights Changed | Every machine, when the headlights or signals change | Traffic cars signal their turns at junctions by themselves. A trailer has no lights of its own: show its truck's. The actions **Headlights**, **Indicator Left**, **Indicator Right**, **Hazard**, **Camera**, **Change Seat** and **Flip Upright** are on the vehicle next to the driving ones; leave any of them empty to handle it yourself. **Honk** sounds the vehicle's **Horn Sound** for everyone within **Horn Hear Radius** (80 m); the **Horn Action** calls it for the driver, traffic calls it on its own. **On Honk** fires on every machine. The chase camera's arm pulls in when something is between it and the vehicle, but vehicles themselves (the body box ignores the Camera channel) never block it: a truck's camera would otherwise sit against its own trailer. Besides the chase camera there is an **Interior Camera** at the driver's eyes (**Interior Camera Offset** from the driver's seat). **Set Interior Camera** switches between them on this machine; a new driver starts with the chase one. Vehicles replicate up to 500 m away (a pawn's default is 150 m, which a car at 150 km/h covers in under 4 s). It is the actor's **Net Cull Distance Squared**, under Replication. ## Tuning `FDRCVehicleSetup` holds everything that makes a vehicle drive: body (mass, center of mass, inertia), wheels (radius, suspension, grip), steering, engine (pull, torque curve, gearbox), brakes, two-wheel balance, damage. - Set it on the vehicle's movement component, or make a **DRC Vehicle Setup Asset** and put it in **Setup Asset** to share one tuning between vehicles of the same model. - Ready-made setups, as functions (**Make ... Setup**) and as assets in **Drivecraft Content/Presets** to put in **Setup Asset** (turn on **Show Plugin Content** in the Content Browser to see them). Size your body box and wheel positions to your mesh after picking one; the rest is the handling. Measured on the lab's straight and course (no network): | Preset | Mass | Drive | 0-100 km/h | Top speed | Biggest slide (slalom / long turn / braking turn) | |---|---|---|---|---|---| | DA_DRCSportsCar | 1.3 t | rear | 5.4 s | 257 of 260 | 4.3 / 4.5 / 4.9 degrees | | DA_DRCSedan (the example car) | 1.5 t | rear | 6.7 s | 158 of 160 | 4.4 / 4.5 / 4.4 | | DA_DRCSUV | 2.1 t | all four | 6.4 s | 187 of 190 | 3.9 / 4.0 / 4.3 | | DA_DRCVan | 2.4 t | front | 10.5 s | 157 of 160 | 3.1 / 3.2 / 1.7 | | DA_DRCBus | 12 t | rear | 0-50 in 7.4 s | 80 in 30 s, of 100 | 2.3 / 2.3 / 5.9 | | DA_DRCTruck with DA_DRCTrailer | 8 t + 6 t | rear two axles | 0-50 in 6.6 s | 92 in 30 s, of 110 | 2.9 / 2.1 / 8.0 | | DA_DRCBike | 250 kg | rear | 5.8 s | 178 of 180 | 4.2 / 4.4 / 9.7 | - The same setup has to be on every machine (it is not sent over the network): set it on the class or the asset, not at runtime on one machine. Things that usually need a look: - **Center Of Mass Offset**: low keeps a car on its wheels. A car tips over when the tyre grip (in g) passes half its track over the center of mass height. - **Body Extent**: keep the box off the road (25 cm or more). A box that touches the road when the car pitches pushes it. - **Suspension Stiffness**: about the weight on the wheel (kg x 980) over 10 cm. How much it slides: - **Steering Grip Limit** (1): at speed the wheels turn no further than the tyres can follow. Lower lets full steering ask for more than the grip, and the car slides; 0 turns it off. Without it, full steering at 100 km/h asks for several g. - **Peak Slip Angle** (5 degrees): about how far the car points off the way it goes when it turns as hard as it can. - **Drive And Brake Grip Share** (0.8): the share of a tyre's grip ABS and traction control let the brakes and the throttle use, the rest kept for turning. 1 lets hard braking or throttle in a turn slide. The brakes work by the weight on each wheel, so braking in a turn does not spin the car. - **Stability Assist** (0, 300 on the bike): turns the vehicle back toward where it goes once the back axle slides past the peak slip angle. A bike needs it to brake in a turn. It watches the back axle, not the center: in a tight slow turn the center goes sideways to where it points without anything sliding. - The handbrake still slides on purpose (**Handbrake Grip Scale**). Track tuning (all off or neutral by default, so a vehicle drives the same until you set them): - **Anti Lock Brakes** (on) and **Traction Control** (on): they hold the brakes and the throttle to Drive And Brake Grip Share. Off, a wheel braked past its grip locks and slides straight on, steering or not; a driven wheel pushed past its grip spins and loses most of its grip sideways. ABS off only shows when **Brake Deceleration** is above the grip. - **Brake Balance** (0.5, by the weight on each wheel): toward 1 the front brakes harder (steady), toward 0 the back (turns in, can spin). - **Front Anti Roll** and **Rear Anti Roll** (0): anti-roll bars, as a share of Suspension Stiffness. They hold the two wheels of an axle to the same compression, so the body leans less; the axle with more slides first. - **Downforce At Top Speed** (0 g): air pressing the car down, growing with the square of the speed. - **Drag At Top Speed** (0.1 g): air holding it back. What each did to the example car on the lab's course (no network): | Change | Result | |---|---| | Anti-roll 0.5 front and back | leans 1.9 degrees in the long turn instead of 3.9 | | Brake Balance 0.3 | slides 19 degrees braking into a turn instead of 4.4 | | Downforce 0.5 g | slides 4.1 degrees in the long turn instead of 4.5, brakes harder | | ABS off, Brake Deceleration 1.5 | locks and goes straight on braking into a turn | | Traction Control off, full throttle turning from a stop | the back steps out and it spins (back axle slides 38 degrees instead of 19) | Measured on the lab's course (no network), the biggest slide in the slalom, a long turn at full steering and a turn while braking hard: car 4.8 degrees at 110-127 km/h, bike 11.7 at 120-140, truck with trailer 7.6 at 40-57 (it was 70 to 90 on all three, the car and the bike spinning). ## Engine and gearbox The engine pulls through a gearbox, simulated with the rest (predicted and corrected over the network like the body): - **Launch Acceleration** (1.2 g): first gear's pull. Above what the tyres hold, the low gears pull as hard as the grip allows. - **Gear Top Speeds**: each gear's top speed as a share of **Top Speed**, the last one 1. They are the ratios too: a gear twice as fast pulls half as hard. Top speed comes from the last gear meeting **Max RPM**, where a rev limiter cuts the pull. - **Torque Curve**: the pull by rpm, 0 to 1 (X in rpm). Empty pulls the same at every rpm. In first gear the clutch slips, so a standing start pulls as at half way between **Idle RPM** and **Max RPM**. - **Automatic Gearbox** (on): shifts up at **Shift Up RPM** (0.92 of Max RPM) and down under **Shift Down RPM** (0.45 of the way from idle). Off, the driver shifts: **Shift Up** and **Shift Down** on the movement component, or the vehicle's **Shift Up Action** and **Shift Down Action**. - **Shift Time** (0.2 s): no pull while the gear changes. - Holding the brake when stopped backs up, in either gearbox. Measured on the lab's straight (no network), full throttle for 30 s: | Vehicle | 0-100 km/h | Fastest in 30 s | Top Speed | |---|---|---|---| | Car (5 gears) | 6.7 s | 158 km/h | 160 | | Bike (6 gears) | 5.8 s | 178 km/h | 180 | | Truck with its trailer (6 gears) | 0-50 in 6.6 s | 92 km/h | 110 | ## Surfaces Each wheel reads the physical material of the ground under it (the mesh material's, or the component's **Phys Material Override**) and looks it up in **Project Settings > Plugins > Drivecraft > Surfaces**: - **Grip**: the share of the tyre's grip it keeps there. Accelerating, braking and turning all scale with it. - **Rolling Resistance**: what rolling costs, as a share of the weight on the wheel. Soft ground slows a car down with the throttle off and holds back its top speed. Ground with no physical material, or one not in the list, uses **Default Surface** (asphalt: 1 and 0.015). The plugin ships three, used by the example: dirt (0.65, 0.03), grass (0.55, 0.05) and ice (0.1, 0.01). **Get Wheel Physical Material** gives what a wheel stands on, for dust, skid sounds or tyre marks. Measured on the lab's course with the example's car (no network), speed after 5 s at full throttle from a stop, and the biggest slide in a long turn at full steering: | Ground | km/h at 5 s | Slide in the long turn | |---|---|---| | Asphalt | 84 | 5 degrees | | Dirt | 49 | 28 degrees | | Grass | 36 | 24 degrees | | Ice | 6.5 | 3 degrees (too slow to slide) | ## Lying over A vehicle on its roof or side rests on the corners of its body box: each corner that touches the ground holds it up with a stiff spring, damping and friction, and once it lies nearly still it stops. It does not rock or creep. Measured in the lab, four cars dropped upside down and on their side: none moved or turned at all after 8 s. **Flip Upright** puts one back on its wheels. ## Damage A hit faster than **Damage From Speed** (18 km/h of closing speed) takes bodywork off, all of it at **Wreck Speed** (110 km/h). A hit at the front damages the engine too (it pulls less, nothing when wrecked), and one near a wheel damages that wheel (it grips down to **Flat Tyre Grip**). **Take Damage** off turns it all off. - **Get Engine Health**, **Get Body Health**, **Get Wheel Health**: 1 whole, 0 gone, as this machine has it. - **On Damaged** fires on every machine when the bodywork took damage. - **Apply Damage At** (server): damage as a crash at a point would do it, for explosions, gunfire or a scripted wreck. - **Repair** (server): back to new.