b3dSetVehicleInput

Sets vehicle control inputs for throttle/brake, steering, and handbrake. Takes vehicleHandle (vehicle from b3dCreateVehicle), forward (-1 to 1, negative=brake, positive=throttle), right (-1 to 1, negative=left, positive=right steering), handBrake (0 to 1, handbrake intensity). Returns nothing.

3D Graphics

Parameters & Returns

Parameters

vehicleHandle Int
forward Double
right Double
handBrake Double

Returns

Void

Quick Summary

Sets vehicle control inputs for throttle/brake, steering, and handbrake. Takes vehicleHandle (vehicle from b3dCreateVehicle), forward (-1 to 1, negative=brake, positive=throttle), right (-1 to 1, negative=left, positive=right steering), handBrake (0 to 1, handbrake intensity). Returns nothing.

Technical Exegesis...

Sets vehicle control inputs for throttle/brake, steering, and handbrake. Takes vehicleHandle (vehicle created with b3dCreateVehicle), forward (-1 to 1 where negative=brake, 0=coast, positive=throttle/accelerate), right (-1 to 1 where negative=steer left, 0=straight, positive=steer right), handBrake (0 to 1 where 0=off, 1=full handbrake). Returns nothing. Updates Jolt WheeledVehicle input state, affects vehicle acceleration/braking/steering in next physics step.

Example

Example.bam
; Simple keyboard control
Repeat
    ; Map arrow keys to vehicle input
    forward = BBR_GetKey(200) - BBR_GetKey(208)  ; Up arrow - Down arrow
    right = BBR_GetKey(205) - BBR_GetKey(203)    ; Right arrow - Left arrow
    handBrake = BBR_GetKey(57)                   ; Space bar

    ; Update vehicle control
    b3dSetVehicleInput(vehicle, forward, right, handBrake)

    b3dRenderWorld()
    BBR_Flip()
Until BBR_GetKey(1)

; Smooth analog control with input smoothing
Global smoothForward! = 0.0
Global smoothRight! = 0.0

Repeat
    ; Target inputs from keyboard
    targetForward = BBR_GetKey(200) - BBR_GetKey(208)
    targetRight = BBR_GetKey(205) - BBR_GetKey(203)

    ; Smooth current inputs toward targets
    smoothForward = smoothForward * 0.85 + targetForward * 0.15
    smoothRight = smoothRight * 0.85 + targetRight * 0.15

    ; Apply smoothed inputs
    b3dSetVehicleInput(vehicle, smoothForward, smoothRight, 0)

    b3dRenderWorld()
    BBR_Flip()
Until BBR_GetKey(1)

; Arcade racing with drift
Repeat
    forward = BBR_GetKey(200) - BBR_GetKey(208)
    right = BBR_GetKey(205) - BBR_GetKey(203)

    ; Use handbrake for drifting in turns
    If Abs(right) > 0.5 And BBR_GetKey(42) Then  ; Shift key for drift
        handBrake = 1.0
    Else
        handBrake = 0.0
    EndIf

    b3dSetVehicleInput(vehicle, forward, right, handBrake)

    b3dRenderWorld()
    BBR_Flip()
Until BBR_GetKey(1)