RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

AI Module ReferenceBackwards Compatibility Module ReferenceBdebug Module ReferenceBdebugImpl Module ReferenceBeamstate Module ReferenceBullettime Module ReferenceController Module ReferenceDamageTracker Module ReferenceDrivetrain Module ReferenceElectrics Module ReferenceElectrics Custom Value ParserEnergyStorage Module ReferenceExtensions Module ReferenceFire Module ReferenceVehicle Engine True GlobalsGuihooks Module ReferenceGUI Streams Module ReferenceHTML Texture Module ReferenceHydros Module ReferenceInput Module ReferenceJBeam-Lua Integration GuideMapmgr Module ReferenceMaterial Module ReferenceBeamNG Math & Unit Conversions Referenceobj (Vehicle C++ Object)PartCondition Module ReferenceParticlefilter Module ReferenceParticles Module ReferencePowertrain Module ReferenceVehicle Property & Module TreeProps Module ReferenceProtocols Module ReferenceRecovery Module ReferenceScriptAI Module ReferenceSensors Module ReferenceSounds Module ReferenceStreams Module ReferenceThrusters Module Reference`v` (Vehicle Data & JBeam)Wheels Module Reference

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referenceve

obj (Vehicle C++ Object)

The `obj` global is a C++ binding to the `Vehicle` object in the engine. It provides direct access to the vehicle's physical state and low-level physics modifications. This is the primary interface fo

The obj global is a C++ binding to the Vehicle object in the engine. It provides direct access to the vehicle's physical state and low-level physics modifications. This is the primary interface for vehicle-side Lua to interact with the C++ physics core.

See Also

  • JBeam Stage 2: For how JBeam is committed via obj.
  • Wheels: For C++ wheel object interaction.
  • Sounds: For persistent SFX handles.
  • Communication: For Inter-VM messaging.
  • Sensors: For high-frequency C++ sensor data.

State Fields

VariableDescription
obj.debugDrawProxyA userdata proxy used for custom C++ level debug visualizations.

Public API - 1. Identification & Lifecycle

FunctionSignatureDescription
obj:getId() / obj:getID()Returns the unique vehicle object ID assigned by the engine.
obj:finishLoading()Finalizes JBeam structural initialization. This must be called if nodes or beams are manually modified during the init sequence.
obj:commitLoad()Commits the currently loaded JBeam structural data to the C++ physics engine.
obj:requestReset(mode)Triggers a vehicle reset.
obj:respawnWithPartConfig(config)Respawns the vehicle instance with a new part configuration.
obj:initLuaCallbacks()Re-initializes the Lua callback triggers for the vehicle object.

Usage Example

local id = obj:getId()
obj:finishLoading()

Public API - 2. World State & Position

FunctionSignatureDescription
obj:getPosition() / obj:getPositionXYZ()Returns the vehicle's world position. getPositionXYZ returns three numbers (x, y, z) for better performance in tight loops.
obj:getRotation()Returns the vehicle's world rotation as a quaternion.
obj:getVelocity() / obj:getVelocityXYZ()Returns the vehicle's world velocity vector.
obj:getDirectionVector() / obj:getDirectionVectorUp() / obj:getDirectionVectorRight()Returns the forward, up, or right unit vectors relative to the vehicle's orientation.
obj:getForwardVector()Alias for getDirectionVector.
obj:getRollPitchYaw() / obj:getRollPitchYawRad()Returns the roll, pitch, and yaw angles of the vehicle in degrees or radians.
obj:getRollPitchYawAngularVelocity()Returns the angular velocity vector for the vehicle's primary axes.
obj:getPitchAngularVelocity() / obj:getRollAngularVelocity() / obj:getYawAngularVelocity()Returns specific angular velocity rates for pitch, roll, or yaw.
obj:getAltitude()Returns the vehicle's height above sea level (Z coordinate).
obj:getGroundSpeed() / obj:getAirSpeed()Returns the vehicle's scalar speed relative to the ground surface or the surrounding air.
obj:getAirflowSpeed() / obj:getFrontAirflowSpeed()Returns airflow speeds measured generally or at the vehicle's front plane.
obj:getFrontPosition() / obj:getFrontPositionRelative()Returns the world or local relative position of the vehicle's front center point.
obj:getCenterPosition() / obj:getObjectCenterPosition()Returns the world position of the vehicle's physical center.
obj:getCornerPosition(idx)Returns the world position of a specific corner of the vehicle's bounding box.
obj:calcCenterOfGravity() / obj:calcCenterOfGravityRel()Calculates the real-time position of the Center of Gravity (COG) in world or relative coordinates.
obj:getInitialHeight() / obj:getInitialLength() / obj:getInitialWidth()Returns the dimensions of the vehicle as originally defined in the JBeam files.
obj:getInitialQuaternion()Returns the vehicle's rotation at the moment of spawning.
obj:getCameraPosition()Returns the world position of the currently active camera attached to this vehicle.

Usage Example

local x, y, z = obj:getPositionXYZ()
local rot = obj:getRotation()

Public API - 3. Environment & Terrain

FunctionSignatureDescription
obj:getGravity() / obj:getGravityVector() / obj:setGravity(val)Accesses or overrides the gravity strength or vector affecting this vehicle.
obj:getWind() / obj:setWind(x, y, z)Gets or sets the ambient wind velocity vector affecting aerodynamics.
obj:getEnvTemperature() / obj:getEnvPressure()Returns the ambient temperature (Kelvin) and atmospheric pressure (Pa) at the vehicle's location.
obj:getAirDensity() / obj:getAirDensityAtSeaLevel() / obj:getRelativeAirDensity()Returns air density data used for drag and engine performance calculations.
obj:getTerrainHeight(x, y) / obj:getTerrainNormal(x, y)Queries the map's terrain height or surface normal vector at specific coordinates.
obj:getTerrainDrivability(x, y)Returns the "drivability" coefficient (grip/roughness) defined for the ground model at that location.
obj:getDistanceFromTerrain() / obj:getDistanceFromTerrainPoint(x, y, z)Returns the vertical distance from the vehicle (or point) to the ground surface.
obj:getSurfaceHeightBelow(x, y, z)Returns the height of the first physical surface detected below the specified point.
obj:inWater(cid) / obj:setWaterFlow(x, y, z)Checks if a node is below the water plane or sets the global water current velocity.
obj:getFlow()Returns the combined water/air flow vector currently acting on the vehicle body.
obj:setPlanets(count)Internal setting for planetary gravity simulation nodes.

Public API - 4. Physics Core & Timing

FunctionSignatureDescription
obj:getPhysicsDt() / obj:getPhysicsFPS()getPhysicsDt returns the fixed time step (default 0.0005s for 2000Hz). getPhysicsFPS returns the actual calculation rate.
obj:getSimTime() / obj:getSimulationTimeScale() / obj:setSimulationTimeScale(scale)Manages the total simulation time elapsed and the speed of physics (slow-motion).
obj:getRealdt()Returns the actual real-world time delta since the last frame, regardless of time scale.
obj:getGraphicsStepCount()Returns the total count of rendered frames.
obj:setPhysicsStepEnabled(enabled)Enables or disables the high-frequency onPhysicsStep callback. Use only for essential 2000Hz logic.
obj:setSleepingEnabled(enabled)Toggles physics optimization where stationary vehicles consume less CPU.
obj:getGhostEnabled() / obj:setGhostEnabled(enabled)Controls collision ghosting (visual-only vehicle).
obj:applyForce(nodeId, x, y, z) / obj:applyForceTime(...)Applies a raw force vector to a single JBeam node.
obj:applyForceVector(nodeId, vector) / obj:applyForceVectorTime(...)Applies a directional force vector to a node.
obj:applyTorqueAxisCouple(magnitude, n1, n2, n3)Applies a torque couple using three nodes to define the torque plane.
obj:calcCenterOfPressureRel()Calculates the relative position of the vehicle's Center of Pressure for aerodynamic forces.
obj:calcTotalAeroForces() / obj:calcTotalAeroTorque()Returns the sum of all aerodynamic drag, lift, and side forces/torques.
obj:setAerodynamicsMode(mode) / obj:getAerodynamicsMode()Configures the fidelity of the aerodynamic simulation.

Public API - 5. Nodes (JBeam)

FunctionSignatureDescription
obj:getNodeCount()Returns the total number of physical nodes in the JBeam structure.
obj:getNodePosition(cid) / obj:getAbsNodePosition(cid)Returns the node's position relative to reference nodes or in world space.
obj:getNodePositionRelativeXYZ(cid)Returns the x, y, z coordinates of the node relative to the vehicle's reference nodes.
obj:setNodePosition(cid, x, y, z)Forcibly teleports a JBeam node to a specific world position.
obj:getNodeMass(cid) / obj:setNodeMass(cid, mass)Gets or dynamically overrides the physical mass of a node.
obj:getNodeVelocity(cid) / obj:getNodeVelocityVector(cid)Returns the current world velocity vector of a node.
obj:getNodeForce(cid) / obj:getNodeForceVector(cid)Returns the instantaneous physical force magnitude or vector acting on a node.
obj:getNodeReactionForce(cid)Returns the reaction force generated by collisions at this node.
obj:getNodeTemperature(cid)Returns the current temperature of a specific node.
obj:getDensityAtNode(cid)Returns the atmospheric density at the node's current location.
obj:getNodeFrictionCoef(cid) / obj:setNodeFrictionSlidingCoefs(cid, f, s)Manages surface friction properties for an individual node.
obj:isNodeColliding(cid)Returns true if the node is currently in physical contact with another object or terrain.
obj:getNodeCluster(cid) / obj:inSameNodeCluster(n1, n2)Checks physical node cluster assignments (used for deformation and optimization).

Public API - 6. Beams (JBeam)

FunctionSignatureDescription
obj:getBeamCount()Returns the total number of physical beams in the structure.
obj:getBeamLength(cid) / obj:getBeamRestLength(cid) / obj:getBeamRefLength(cid)Returns the current, rest, or reference length of a structural beam.
obj:getBeamForce(cid) / obj:getBeamStress(cid)Returns the current physical force or internal stress value of a beam.
obj:getBeamDeformation(cid) / obj:getBeamDebugDeformation(cid)Returns the permanent deformation ratio (strain residue) of a beam.
obj:beamIsBroken(cid) / obj:breakBeam(cid)Boolean status check or manual structural breakage of a beam.
obj:setBeam(cid, ...) / obj:setBeamSpringDamp(cid, s, d) / obj:setBeamStrength(cid, s)Dynamically overrides physical properties of a structural beam.
obj:setPrecompressionRatio(cid, r)Sets the precompression target for a beam (used for active suspension or structural tension).
obj:actuateBeam(cid, ...)Directly actuates a beam (e.g., hydraulic pistons).

Public API - 7. Dynamic Beams

FunctionSignatureDescription
obj:addDynamicBeamNode(n1, n2, ...)Creates a new physical beam at runtime between two existing nodes.
obj:deleteDynamicBeam(id) / obj:deleteAllDynamicBeam()Removes dynamically created structural beams.

Public API - 8. Triangles & Rails (JBeam)

FunctionSignatureDescription
obj:getTriangleCount() / obj:isTriangleBroken(tid) / obj:breakCollisionTriangle(tid)Manages collision and aerodynamic triangles.
obj:addRail(id, ...) / obj:addRailLink(id, ...) / obj:breakRails(id)Manages physical paths (rails) used by slidenodes.

Public API - 9. Slidenodes & Couplers

FunctionSignatureDescription
obj:addSlidenode(id, ...) / obj:attachSlidenode(id, ...) / obj:detachSlidenode(id)Manages nodes that are constrained to slide along predefined physical rails.
obj:attachCoupler(id, ...) / obj:detachCoupler(id) / obj:stopLatching()Manages structural coupling/uncoupling logic (e.g., trailers, doors).
obj:externalCouplerCount()Returns the total count of active external structural connections.

Public API - 10. Wheels & Tires

FunctionSignatureDescription
obj:getWheel(idx)Returns a handle to the C++ Wheel object for specialized physics queries.
obj:getWheelAvgTemperature(idx) / obj:getWheelCoreTemperature(idx)Returns the current averaged or core temperature of the tire.
obj:setWheelTorqueAndBrakeTorque(idx, t, b)Directly overrides the torques applied to a specific wheel.
obj:wheelTurnRadius(wid)Returns the current calculated steering turn radius for a specific wheel.
obj:setSlipTireMarkThreshold(t)Sets the wheel slip energy level required to trigger skid mark rendering.

Public API - 11. Visuals & Materials

FunctionSignatureDescription
obj:switchMaterial(msc, mat) / obj:resetMaterials(msc)Swaps material states for visual effects (glowmaps, cracked glass).
obj:getSwitchableMaterial(msc)Returns the name of the material currently active on a specific JBeam material switch.
obj:setMaterialEmissiveFactor(msc, color)Controls the intensity and color of emissive materials (e.g., dashboards, headlights).
obj:setPropLight(id, b, s, c)Configures point light and flare properties for moving JBeam props.
obj:addDecal(pos, normal, ...) / obj:addParticle(pos, vel, ...)Spawns world decals (skid marks, mud) or physical particles (smoke, sparks).

Public API - 12. Audio & SFX

FunctionSignatureDescription
obj:createSFXSource(s, p, d, n, f)Creates a persistent 3D sound source handle attached to a vehicle node.
obj:playSFX(id) / obj:stopSFX(id) / obj:isPlayingSFX(id)Controls persistent audio playback.
obj:playSFXOnce(sample, node, v, p)Triggers a non-looping 3D sound effect at a node's location.
obj:setSFXparameter(id, name, val) / obj:setVolumePitch(id, v, p)Real-time updates for active sound sources.

Public API - 13. UI & Web

FunctionSignatureDescription
obj:createWebView(w, h) / obj:queueWebViewJS(id, js)Manages high-performance in-game web textures used for digital dashboards.
obj:sendRPMLeds(rpm, min, max)Updates hardware LED indicators on supported peripherals.
obj:setDebugString(str)Overlays text on the screen for vehicle-specific debug logging.

Public API - 14. Inter-VM & Communication

FunctionSignatureDescription
obj:queueLuaCommand(cmd)Schedules code to run in the Vehicle context during the next update cycle.
obj:queueGameEngineLua(cmd)Sends code to the Game Engine (GE) Lua context for world-level execution.
obj:queueObjectLuaCommand(id, cmd)Sends code to be executed in the context of another vehicle instance.
obj:sendForceFeedback(type, mag)Sends torque feedback signals to the player's hardware controller.

Public API - 15. Torsion Bars

FunctionSignatureDescription
obj:getTorsionbarAngle(id) / obj:torsionbarIsBroken(id)Accesses the physical state of torsional spring components.
obj:setTorsionbarAngle(id, a)Manually sets the target twist angle for a torsion bar.

Public API - 16. Sensors

FunctionSignatureDescription
obj:getSensorVectorRaw(name)Returns raw vector data from high-frequency C++ sensors.
obj:getSensorX() / obj:getSensorY() / obj:getSensorZ()Returns G-force/accelerometer sensor components.
obj:getSensorsFFI()Returns an FFI pointer for the most efficient possible sensor data access.

Public API - 17. Pressure Groups

FunctionSignatureDescription
obj:getGroupPressure(group) / obj:setGroupPressure(group, p)Manages absolute internal pressure for JBeam pressure groups (e.g., tires).
obj:deflatePressureGroup(group)Triggers immediate and rapid pressure loss for a group.

BeamNG Math & Unit Conversions Reference

A centralized reference for common unit conversions and math constants used in BeamNG vehicle Lua.

PartCondition Module Reference

Module defined in `lua/vehicle/partCondition.lua`. Tracks the long-term health, mileage (odometer), and visual wear of every installed vehicle part. Used by the career/campaign systems to persist vehicle condition across sessions — parts degrade over time and use, affecting both gameplay (repair costs, performance) and visuals (paint wear, rust). Supports condition snapshots for save/restore.

On this page

See AlsoState FieldsPublic API - 1. Identification & LifecycleUsage ExamplePublic API - 2. World State & PositionUsage ExamplePublic API - 3. Environment & TerrainPublic API - 4. Physics Core & TimingPublic API - 5. Nodes (JBeam)Public API - 6. Beams (JBeam)Public API - 7. Dynamic BeamsPublic API - 8. Triangles & Rails (JBeam)Public API - 9. Slidenodes & CouplersPublic API - 10. Wheels & TiresPublic API - 11. Visuals & MaterialsPublic API - 12. Audio & SFXPublic API - 13. UI & WebPublic API - 14. Inter-VM & CommunicationPublic API - 15. Torsion BarsPublic API - 16. SensorsPublic API - 17. Pressure Groups