Builtin Library
README.md
tyres
Tyre (tire) presets for WheelCollider wheels: each is the set of fields that states one kind of tyre's grip curve, its peak, how it falls off past the peak and how its grip per newton falls with load.
A WheelCollider tyre's force rises with its slip (the slip ratio along the road, the slip angle across it) to its peak, forwardFriction and sidewaysFriction times its load, at the slip its stiffness (forwardFrictionStiffness, sideFrictionStiffness times corneringStiffness) reaches it; past the peak it falls in a straight line to slideGrip of it by slideSlip times the peak slip, and stays there. A loadSensitivity above 0 scales the tyre's grip per newton by (load / referenceLoad) ^ -loadSensitivity. The fall-off acts on a wheel that spins on its own (inertia above 0); a wheel with no inertia grips up to its peak and holds it. Physics.tyreCurve(wheelId) measures the curve a wheel states.
| Preset | Tyre |
|---|---|
road | The WheelCollider defaults with a little load sensitivity. |
grippy | More grip and stiffness; keeps most of its grip in a slide. |
peaky | High grip to its peak, then lets go at once onto half of it. |
drift | A soft peak and a long, gentle fall-off that holds a slide. |
loose | Lower grip and stiffness, a slide nearly as good as its peak (gravel, dirt, grass). |
ice | A tyre on ice. |
heavy | Grips with markedly less per newton as its load rises past 12 kN. |
Exports
Tyres.names() -> { string }: every preset's name.Tyres.get(name) -> table: the preset's fields.Tyres.with(name, config?) -> table: the preset withconfig's fields over it, forcomponent.add("WheelCollider", ...).Tyres.apply(wheel, name): set the preset's fields on a wheel's existing WheelCollider.
local Tyres = require("@builtin::modules.tyres")
wheel.component.add("WheelCollider", Tyres.with("drift", { radius = 0.35, inertia = 1.2 }))
local curve = Physics.tyreCurve(wheel.id)
print(curve.loads[1].side.peak.slipAngle, curve.loads[1].side.peak.perLoad)
A preset is a starting point: any field of a WheelCollider can be set on its own, and any curve its fields state is a curve the engine takes.