Lua ScriptingAdvanced

Vehicles, constraints, and navigation

Drive wheeled and tracked vehicles, operate constraint motors, and move navigation agents.

Wheeled vehicles

setDriverInput(forward,right,brake,handBrake) accepts normalized inputs. Positive right steers right at the Lua API boundary. Separate setters are also available: setForwardInput, setRightInput, setBrakeInput, and setHandBrakeInput.

Read state with getVehicleForwardSpeed(), getVehicleRPM(), getVehicleGear(), isWheelInContact(index), and getWheelContactNormal(index). Runtime tuning methods include setMaxSteerAngle, setEngineTorque, and setMaxBrakeTorque.

Tracked vehicles

setTrackDriverInput(forward,leftRatio,rightRatio,brake) uses independent track ratios for skid steering. setLeftRatio and setRightRatio update them independently.

Constraint motors

Hinge and slider constraints expose setConstraintMotorState("off"|"velocity"|"position"), setConstraintTargetVelocity(value), setConstraintTargetPosition(value), and getConstraintCurrentValue().

Navigation agents

Register an object with registerForPathfinding(moveSpeed?). Then use moveTo(x,y,z), followPath(waypoints), stopMovement(), isMoving(), and getPathToTarget(x,y,z).