Log inGet started
World

Torque Valley: Driving, Drift and Crash Sandbox

README.md

ShowcaseDriver

Drives the driveCams test car. With controlSource = "script" it laps an oval by itself: each frame it steers toward a point a little ahead on an ellipse centred at (centerX, centerZ) with radii radiusX / radiusZ, and holds speed m/s. With controlSource = "input" the player drives it through the package's own showcaseDrive controls (W A S D, a gamepad or touch). Either way it writes drive torque, brakes and steering straight onto the chassis's WheelColliders, so the car needs no engine vehicle component, and it states car.speed / car.kmh for the cameras. A car left on its roof rights itself after 3 s. Only the peer that owns the car drives it.

local car = require("driveCams.showcase").makeCar({ 0, 1.2, 0 })
local driver = car.component.get("driveCams.ShowcaseDriver")
driver.centerX, driver.centerZ, driver.speed = 0, 0, 16
driver.driving = true

It works on any chassis whose child entities carry WheelColliders: the ones in front of the centre (local z < 0) steer, and all four drive.