API ReferenceGE Extensionsflowgraphnodesvehicle
Gravity Force
- **Node Name:** `Gravity Force`
Overview
- Node Name:
Gravity Force - Category:
repeat_p_duration - File:
extensions/flowgraph/nodes/vehicle/gForce.lua
Gets the g-force (gravity force) values of a vehicle, split into lateral (X), longitudinal (Y), and vertical (Z) components, plus total magnitude.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
vehId | number | Vehicle ID; if not provided, uses current player vehicle |
Output Pins
| Pin | Type | Description |
|---|---|---|
gx | number | Lateral acceleration in g |
gy | number | Longitudinal acceleration in g |
gz | number | Vertical acceleration in g (gravity-compensated) |
gForce | number | Total acceleration magnitude in g |
gForceZ0 | number | (hidden) Total acceleration ignoring vertical component |
Internals
Key Methods
| Method | Description |
|---|---|
init() / _executionStarted() / _executionStopped() | Reset state via onNodeReset() |
onNodeReset() | Placeholder for unregistering cached values |
work() | Reads smoothed acceleration values from the vehicle bridge cache, normalizes by gravity, outputs g-force components |
Cached Values
The node reads these from core_vehicleBridge.getCachedVehicleData:
| Key | Description |
|---|---|
accXSmooth | Smoothed lateral acceleration |
accYSmooth | Smoothed longitudinal acceleration |
accZSmooth | Smoothed vertical acceleration |
How It Works
- Each frame,
work()fetches the vehicle's smoothed acceleration values from the vehicle bridge cache. - If a value isn't cached yet, it calls
core_vehicleBridge.registerValueChangeNotification(veh, key)to start tracking it. - The current gravity is fetched via
core_environment.getGravity()(clamped to min 0.01 to avoid division by zero). - G-force components are computed:
gx = accXSmooth / gravity(lateral)gy = accYSmooth / gravity(longitudinal)gz = (accZSmooth - gravity) / gravity(vertical, compensated for resting gravity)
- Total g-force:
sqrt(gx² + gy² + gz²), andgForceZ0ignores the Z component.
Usage Example
-- In a flowgraph:
-- [Gravity Force] → gForce → [Compare > 2.0] → [Trigger Blackout Effect]
-- → gx → [Display Lateral G]
-- Programmatic equivalent:
local accX = core_vehicleBridge.getCachedVehicleData(vehId, 'accXSmooth') or 0
local gravity = math.abs(core_environment.getGravity())
local gx = accX / gravityKey Dependencies
core_vehicleBridge.getCachedVehicleData()- reads cached vehicle telemetrycore_vehicleBridge.registerValueChangeNotification()- subscribes to vehicle data updatescore_environment.getGravity()- returns current world gravity value
See Also
- Align for Coupling (Flowgraph Node) - Related reference
- Apply Velocity to Vehicle (Flowgraph Node) - Related reference
- Boost Vehicle (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide