# Class DynamicRayCastVehicleController

A character controller to simulate vehicles using ray-casting for the wheels.

- Defined in control/ray_cast_vehicle_controller.d.ts:8

#####
Index

### Constructors

constructor

### Properties

_chassis
bodies
broadPhase
colliders
narrowPhase
raw

### Accessors

indexForwardAxis
indexUpAxis
setIndexForwardAxis

### Methods

addWheel
chassis
currentVehicleSpeed
free
numWheels
setWheelAxleCs
setWheelBrake
setWheelChassisConnectionPointCs
setWheelDirectionCs
setWheelEngineForce
setWheelFrictionSlip
setWheelMaxSuspensionForce
setWheelMaxSuspensionTravel
setWheelRadius
setWheelSideFrictionStiffness
setWheelSteering
setWheelSuspensionCompression
setWheelSuspensionRelaxation
setWheelSuspensionRestLength
setWheelSuspensionStiffness
updateVehicle
wheelAxleCs
wheelBrake
wheelChassisConnectionPointCs
wheelContactNormal
wheelContactPoint
wheelDirectionCs
wheelEngineForce
wheelForwardImpulse
wheelFrictionSlip
wheelGroundObject
wheelHardPoint
wheelIsInContact
wheelMaxSuspensionForce
wheelMaxSuspensionTravel
wheelRadius
wheelRotation
wheelSideFrictionStiffness
wheelSideImpulse
wheelSteering
wheelSuspensionCompression
wheelSuspensionForce
wheelSuspensionLength
wheelSuspensionRelaxation
wheelSuspensionRestLength
wheelSuspensionStiffness

## Constructors

### constructor

- new DynamicRayCastVehicleController(chassis, broadPhase, narrowPhase, bodies, colliders): DynamicRayCastVehicleController

- #### Parameters

  - chassis: RigidBody
  - broadPhase: BroadPhase
  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

  #### Returns DynamicRayCastVehicleController

  - Defined in control/ray_cast_vehicle_controller.d.ts:15

## Properties

### `Private` _chassis

_chassis: any

- Defined in control/ray_cast_vehicle_controller.d.ts:14

### `Private` bodies

bodies: any

- Defined in control/ray_cast_vehicle_controller.d.ts:12

### `Private` broadPhase

broadPhase: any

- Defined in control/ray_cast_vehicle_controller.d.ts:10

### `Private` colliders

colliders: any

- Defined in control/ray_cast_vehicle_controller.d.ts:13

### `Private` narrowPhase

narrowPhase: any

- Defined in control/ray_cast_vehicle_controller.d.ts:11

### `Private` raw

raw: any

- Defined in control/ray_cast_vehicle_controller.d.ts:9

## Accessors

### indexForwardAxis

- get indexForwardAxis(): number

- The chassis’ local forward direction (`0 = x, 1 = y, 2 = z`).

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:48

### indexUpAxis

- get indexUpAxis(): number

- The chassis’ local up direction (`0 = x, 1 = y, 2 = z`).

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:40
- set indexUpAxis(axis): void

- Sets the chassis’ local up direction (`0 = x, 1 = y, 2 = z`).

  #### Parameters

  - axis: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:44

### setIndexForwardAxis

- set setIndexForwardAxis(axis): void

- Sets the chassis’ local forward direction (`0 = x, 1 = y, 2 = z`).

  #### Parameters

  - axis: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:52

## Methods

### addWheel

- addWheel(chassisConnectionCs, directionCs, axleCs, suspensionRestLength, radius): void

- Adds a new wheel attached to this vehicle.

  #### Parameters

  - chassisConnectionCs: Vector

    The position of the wheel relative to the chassis.

  - directionCs: Vector

    The direction of the wheel’s suspension, relative to the chassis. The ray-casting will happen following this direction to detect the ground.

  - axleCs: Vector

    The wheel’s axle axis, relative to the chassis.

  - suspensionRestLength: number

    The rest length of the wheel’s suspension spring.

  - radius: number

    The wheel’s radius.

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:62

### chassis

- chassis(): RigidBody

- The rigid-body used as the chassis.

  #### Returns RigidBody

  - Defined in control/ray_cast_vehicle_controller.d.ts:36

### currentVehicleSpeed

- currentVehicleSpeed(): number

- The current forward speed of the vehicle.

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:32

### free

- free(): void
- `Internal`

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:17

### numWheels

- numWheels(): number

- The number of wheels attached to this vehicle.

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:66

### setWheelAxleCs

- setWheelAxleCs(i, value): void

- Sets the i-th wheel’s axle axis, relative to the chassis.

  The axis index defined as 0 = X, 1 = Y, 2 = Z.

  #### Parameters

  - i: number
  - value: Vector

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:186

### setWheelBrake

- setWheelBrake(i, value): void

- Set the maximum amount of braking impulse applied on the i-th wheel to slow down the vehicle.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:146

### setWheelChassisConnectionPointCs

- setWheelChassisConnectionPointCs(i, value): void

- Sets the position of the i-th wheel, relative to the chassis.

  #### Parameters

  - i: number
  - value: Vector

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:74

### setWheelDirectionCs

- setWheelDirectionCs(i, value): void

- Sets the direction of the i-th wheel’s suspension, relative to the chassis.

  The ray-casting will happen following this direction to detect the ground.

  #### Parameters

  - i: number
  - value: Vector

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:174

### setWheelEngineForce

- setWheelEngineForce(i, value): void

- Sets the forward force applied by the i-th wheel on the chassis.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:162

### setWheelFrictionSlip

- setWheelFrictionSlip(i, value): void

- Sets the parameter controlling how much traction the tire has.

  The larger the value, the more instantaneous braking will happen (with the risk of causing the vehicle to flip if it’s too strong).

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:200

### setWheelMaxSuspensionForce

- setWheelMaxSuspensionForce(i, value): void

- Sets the maximum force applied by the i-th wheel’s suspension.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:138

### setWheelMaxSuspensionTravel

- setWheelMaxSuspensionTravel(i, value): void

- Sets the maximum distance the i-th wheel suspension can travel before and after its resting length.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:90

### setWheelRadius

- setWheelRadius(i, value): void

- Sets the i-th wheel’s radius.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:98

### setWheelSideFrictionStiffness

- setWheelSideFrictionStiffness(i, value): void

- The multiplier of friction between a tire and the collider it’s on top of.

  The larger the value, the stronger side friction will be.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:212

### setWheelSteering

- setWheelSteering(i, value): void

- Sets the steering angle (radians) for the i-th wheel.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:154

### setWheelSuspensionCompression

- setWheelSuspensionCompression(i, value): void

- The i-th wheel’s suspension’s damping when it is being compressed.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:118

### setWheelSuspensionRelaxation

- setWheelSuspensionRelaxation(i, value): void

- Sets the i-th wheel’s suspension’s damping when it is being released.

  Increase this value if the suspension appears to overshoot.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:130

### setWheelSuspensionRestLength

- setWheelSuspensionRestLength(i, value): void

- Sets the rest length of the i-th wheel’s suspension spring.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:82

### setWheelSuspensionStiffness

- setWheelSuspensionStiffness(i, value): void

- Sets the i-th wheel’s suspension stiffness.

  Increase this value if the suspension appears to not push the vehicle strong enough.

  #### Parameters

  - i: number
  - value: number

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:110

### updateVehicle

- updateVehicle(dt, filterFlags?, filterGroups?, filterPredicate?): void

- Updates the vehicle’s velocity based on its suspension, engine force, and brake.

  This directly updates the velocity of its chassis rigid-body.

  #### Parameters

  - dt: number

    Time increment used to integrate forces.

  - `Optional` filterFlags: QueryFilterFlags

    Flag to exclude categories of objects from the wheels’ ray-cast.

  - `Optional` filterGroups: number

    Only colliders compatible with these groups will be hit by the wheels’ ray-casts.

  - `Optional` filterPredicate: ((collider) => boolean)

    Callback to filter out which collider will be hit by the wheels’ ray-casts.

    - - (collider): boolean

      - #### Parameters

        - collider: Collider

        #### Returns boolean

  #### Returns void

  - Defined in control/ray_cast_vehicle_controller.d.ts:28

### wheelAxleCs

- wheelAxleCs(i): Vector

- The i-th wheel’s axle axis, relative to the chassis.

  The axis index defined as 0 = X, 1 = Y, 2 = Z.

  #### Parameters

  - i: number

  #### Returns Vector

  - Defined in control/ray_cast_vehicle_controller.d.ts:180

### wheelBrake

- wheelBrake(i): number

- The maximum amount of braking impulse applied on the i-th wheel to slow down the vehicle.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:142

### wheelChassisConnectionPointCs

- wheelChassisConnectionPointCs(i): Vector

- The position of the i-th wheel, relative to the chassis.

  #### Parameters

  - i: number

  #### Returns Vector

  - Defined in control/ray_cast_vehicle_controller.d.ts:70

### wheelContactNormal

- wheelContactNormal(i): Vector

- The (world-space) contact normal between the i-th wheel and the floor.

  #### Parameters

  - i: number

  #### Returns Vector

  - Defined in control/ray_cast_vehicle_controller.d.ts:232

### wheelContactPoint

- wheelContactPoint(i): Vector

- The (world-space) point hit by the wheel’s ray-cast for the i-th wheel.

  #### Parameters

  - i: number

  #### Returns Vector

  - Defined in control/ray_cast_vehicle_controller.d.ts:236

### wheelDirectionCs

- wheelDirectionCs(i): Vector

- The direction of the i-th wheel’s suspension, relative to the chassis.

  The ray-casting will happen following this direction to detect the ground.

  #### Parameters

  - i: number

  #### Returns Vector

  - Defined in control/ray_cast_vehicle_controller.d.ts:168

### wheelEngineForce

- wheelEngineForce(i): number

- The forward force applied by the i-th wheel on the chassis.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:158

### wheelForwardImpulse

- wheelForwardImpulse(i): number

- The forward impulses applied by the i-th wheel on the chassis.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:220

### wheelFrictionSlip

- wheelFrictionSlip(i): number

- Parameter controlling how much traction the tire has.

  The larger the value, the more instantaneous braking will happen (with the risk of causing the vehicle to flip if it’s too strong).

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:193

### wheelGroundObject

- wheelGroundObject(i): Collider

- The collider hit by the ray-cast for the i-th wheel.

  #### Parameters

  - i: number

  #### Returns Collider

  - Defined in control/ray_cast_vehicle_controller.d.ts:252

### wheelHardPoint

- wheelHardPoint(i): Vector

- The (world-space) starting point of the ray-cast for the i-th wheel.

  #### Parameters

  - i: number

  #### Returns Vector

  - Defined in control/ray_cast_vehicle_controller.d.ts:244

### wheelIsInContact

- wheelIsInContact(i): boolean

- Is the i-th wheel in contact with the ground?

  #### Parameters

  - i: number

  #### Returns boolean

  - Defined in control/ray_cast_vehicle_controller.d.ts:248

### wheelMaxSuspensionForce

- wheelMaxSuspensionForce(i): number

- The maximum force applied by the i-th wheel’s suspension.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:134

### wheelMaxSuspensionTravel

- wheelMaxSuspensionTravel(i): number

- The maximum distance the i-th wheel suspension can travel before and after its resting length.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:86

### wheelRadius

- wheelRadius(i): number

- The i-th wheel’s radius.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:94

### wheelRotation

- wheelRotation(i): number

- The i-th wheel’s current rotation angle (radians) on its axle.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:216

### wheelSideFrictionStiffness

- wheelSideFrictionStiffness(i): number

- The multiplier of friction between a tire and the collider it’s on top of.

  The larger the value, the stronger side friction will be.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:206

### wheelSideImpulse

- wheelSideImpulse(i): number

- The side impulses applied by the i-th wheel on the chassis.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:224

### wheelSteering

- wheelSteering(i): number

- The steering angle (radians) for the i-th wheel.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:150

### wheelSuspensionCompression

- wheelSuspensionCompression(i): number

- The i-th wheel’s suspension’s damping when it is being compressed.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:114

### wheelSuspensionForce

- wheelSuspensionForce(i): number

- The force applied by the i-th wheel suspension.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:228

### wheelSuspensionLength

- wheelSuspensionLength(i): number

- The suspension length for the i-th wheel.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:240

### wheelSuspensionRelaxation

- wheelSuspensionRelaxation(i): number

- The i-th wheel’s suspension’s damping when it is being released.

  Increase this value if the suspension appears to overshoot.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:124

### wheelSuspensionRestLength

- wheelSuspensionRestLength(i): number

- The rest length of the i-th wheel’s suspension spring.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:78

### wheelSuspensionStiffness

- wheelSuspensionStiffness(i): number

- The i-th wheel’s suspension stiffness.

  Increase this value if the suspension appears to not push the vehicle strong enough.

  #### Parameters

  - i: number

  #### Returns number

  - Defined in control/ray_cast_vehicle_controller.d.ts:104