Skip to main content

Vehicle

Contains functions for controlling the Vehicle Entity.

info

This module can only be used in Entity scripts.

Properties​

maxSpeed​

Gets/sets the current maximum normal speed.

maxSpeedBoosting​

Gets/sets the current maximum speed during boosting.

reverseSpeed​

Gets/sets the current maximum reverse speed.

acceleration​

Gets/sets the current acceleration speed.

deceleration​

Gets/sets the current deceleration speed.

maxSteerStrength​

Gets/sets the current maximum steer strength. Bigger values will make the vehicle turn sharper.

steerAcceleration​

Gets/sets the current maximum steer acceleration. This defines how fast the vehicle can steer.

steerDeceleration​

Gets/sets how fast the vehicle can stop steering when user is not pressing any buttons. Can be used to simulate inertia.

speedToDrift​

Gets/sets the minimum speed that the vehicle must be going to start drifting.

driftDuration​

Gets/sets the maximum duration of a drift (in seconds).

boostDuration​

Gets/sets the maximum duration of te boost (in seconds).

boostCooldown​

Gets/sets the time it takes to recharge the boost from empty to full (in seconds). Recharge time will be less if user did not use all the boost.

damageRate​

Gets/sets the amount of damage the vehicle inflicts when colliding with other objects. Damage is calculated as the relative speed between the vehicle and the other object and multiplied by this value. Default value is 5.

useMouseSteering​

Gets/sets if the car is steered by the mouse instead of the keyboard.

cameraRecenterMode​

Gets/sets the current camera recenter mode. By default the camera will recenter only for the driver.

entityDamageMultiplier​

Gets/sets the multiplier for the damage the vehicle takes when colliding with other objects.

playerDamageMultiplier​

Gets/sets the multiplier for the damage the player takes when colliding with the vehicle.

gearCount​

Gets/sets the vehicle gear count.

gearChangeTime​

Gets/sets the time it takes to change gears (in seconds).

suspensionStrength​

Gets/sets the suspension strength. This value should be higher for heavier vehicles.

suspensionDamping​

Gets/sets the suspension damping. Higher values will make the vehicle bounce less.

tireGrip​

Gets/sets tire grip [0, 1].

airControlFactor​

Gets/sets the factor of control the player has in the air [0, 1].

airBoostEnabled​

Gets/sets if boosting in the air will affect the vehicle's propulsion.

jumpEnabled​

Gets/sets if the vehicle can jump. Jump will replace the drift.

jumpPower​

Gets/sets the jump power. This only works if jump is enabled.

cruiseControlSpeed​

Gets/sets the cruise control speed. After accelerating past a certain point, the vehicle will automatically try to reach this speed and will never go faster than this speed.

forceSelfDriving​

Gets/Sets self driving state. When true, the driver of the vehicle will not be able to override automatic navigation.

configLocked​

Gets/Sets config lock Once set to true, the vehicle's config will be impossible to modify.

inputBias​

Gets/sets the input bias. Controls how much the input from Lua will overwrite the input from the player. [0, 1] where 1 is full control over the vehicle. When no driver is present, the input bias is always 1.

accelerationInput​

Gets/sets the acceleration input to the vehicle [-1, 1].

steerInput​

Gets/sets the steer input to the vehicle [-1, 1].

boostInput​

Gets/sets the boost input to the vehicle (boolean).

driftInput​

Gets/sets the drift input to the vehicle (boolean).

Functions​

setInputBias(bias)​

Sets the input bias. Controls how much the input from Lua will overwrite the input from the player. [0, 1] where 1 is full control over the vehicle. When no driver is present, the input bias is always 1.


setAccelerationInput(input)​

Sets the acceleration input to the vehicle [-1, 1].

Parameters​

  • input — Input value that makes vehicle go forward or backwards [-1, 1].

setSteerInput(input)​

Sets the steer input to the vehicle [-1, 1].

Parameters​

  • input — Input value that makes vehicle go left or right [-1, 1].

setBoostInput(input)​

Sets the boost input to the vehicle (boolean).

Parameters​

  • input — Vehicle will boost if set to true.

setDriftInput(input)​

Sets the drift input to the vehicle (boolean).

Parameters​

  • input — Vehicle will drift if set to true.

steerTo(direction)​

Steers the vehicle to a specified direction. Will block code execution until the vehicle has finished steering, but if failed to steer for more than 5 seconds, the function will exit with a warning.

Parameters​

  • direction — Either a number representing the angle in degrees or a Vector3 representing the direction.

setCruise(speed)​

sets the cruise control speed. After accelerating past a certain point, the vehicle will automatically try to reach this speed and will never go faster than this speed.

Parameters​

  • speed — Speed to maintain.

brake()​

Makes the vehicle stop. Will block code execution until the vehicle has fully stopped.


Navigates vehicle to a specified position. Vehicle parameters will impact the accuracy of the path traversal.

Parameters​

  • position — Target point to navigate to.
  • pathConfig — Configuration for path generation behaviour: simplify - if the path should be simplified using funnel algorithm (boolean). smooth - if the path should be smoothed (boolean). graphType - GraphType to use for path generation.
  • navigationConfig — Configuration for the navigation behaviour: reverse - if the vehicle should head for the target backwards turnSpeedMultiplier - increases the speed that vehicle has while turning (number). lookahead - amount of future points on the path to look at to predict turns (number). maxAccelerationAngle - angle to the next path point used to control current vehicle acceleration. Smaller angles make vehicle go slower (number). minBreakAngle - minimum angle to the next path point or a lookahead point at which vehicle will start breaking (number). minDriftAngle - minimum angle to a lookahead point at which vehicle will start drifting (number).

Navigates vehicle through a specified path.

Parameters​

  • path — A collection of Vector3 points to navigate through.

rechargeBoost(amount)​

Recharges boost by a specified amount.

Parameters​

  • amount — Amount to recharge from 0 to 1.

useVehicleAction(actionName)​

Calls special vehicle actions by name. Valid actions will depend on the target vehicle.

Parameters​

  • actionName — Name of the vehicle's action.

Enums​

CameraRecenterMode​

  • None — value = 0
  • DriverOnly — value = 1
  • Everyone — value = 2