Ground Contact
Reference for `gameplay_util_groundContact`, a simple utility that checks whether a vehicle is resting on its wheels (right-side-up and touching the ground).
Reference for gameplay_util_groundContact, a simple utility that checks whether a vehicle is resting on its wheels (right-side-up and touching the ground).
Module Exports (M)
| Function | Signature | Description |
|---|---|---|
isOnWheels | (vehId) → bool | Returns true if the vehicle's bottom is within ground contact distance |
Internals
Detection Method
- Gets the vehicle's oriented bounding box (OOBB) center position
- Adjusts Z position to the bottom of the bounding box + 0.3m offset
- Casts a static ray downward (1.5m max length)
- Returns
trueif the ray hits within 1.1m
Constants
| Constant | Value | Description |
|---|---|---|
raycastLength | 1.5 | Maximum downward ray distance |
maxGroundDistance | 1.1 | Maximum distance to consider "on wheels" |
| Z offset | +0.3 | Offset from bottom of OOBB for ray origin |
M.isOnWheels | (vehId) | - |
Requirements
- Requires
map.objects[vehId]to exist (vehicle must be in the map system) - Uses
castRayStaticfor ground detection (only checks static geometry, not other vehicles)
How It Works
The function checks if the bottom of the vehicle's bounding box is close to static ground geometry. The 0.3m offset from the OOBB bottom accounts for wheel/suspension travel. If the downward raycast hits within 1.1m, the vehicle is considered to be resting on its wheels.
This is a simple check - it doesn't verify individual wheel contact or distinguish between being on wheels vs being on the roof near the ground.
Usage Example
-- Check if player vehicle is on its wheels
local vehId = be:getPlayerVehicleID(0)
if gameplay_util_groundContact.isOnWheels(vehId) then
log("I", "", "Vehicle is on its wheels")
else
log("I", "", "Vehicle is flipped or airborne")
endSee Also
- gameplay/util/crashDetection - Vehicle Crash Detection System - Related reference
- gameplay/util/damageAssessment - Vehicle Damage Location Assessment - Related reference
- gameplay/util/sortedList - Sorted Object List Container - Related reference
- Gameplay Systems Guide - Guide
Damage Assessment
Reference for `gameplay_util_damageAssessment`, which provides spatial damage analysis by dividing a vehicle's bounding box into a 3×3×3 grid (27 sections) and determining which body regions sustained
Sorted List
Reference for `gameplay_util_sortedList`, a generic container that manages a list of named, ID-bearing objects with sorted ordering, name-based lookup, and serialization support.