Skip to main content

HVehicle

HVehicle constructor and functions. This allows you to spawn a vehicle actor in the world and perform logical actions through class methods. This class also provides getter methods, allowing you to obtain data relating to specific vehicle actors.

Example
local vehicle = HVehicle(
UE.FVector(-7940, 3400, 150),
UE.FRotator(0, 180, 0),
'/abcca-dax-veh/PongaseraGt/Blueprint/BP_PongaseraGtVehicle.BP_PongaseraGtVehicle_C',
'QueryAndPhysics',
true
)

vehicle:SetFuel(1.0)

Constructorโ€‹

  • returns: table โ€” HVehicle wrapper with .Object (vehicle actor) and .Movement (UModularMovementComponent)
local vehicle = HVehicle(
Vector(0, 0, 0),
Rotator(0, 0, 0),
'/abcca-dax-veh/PongaseraGt/Blueprint/BP_PongaseraGtVehicle.BP_PongaseraGtVehicle_C',
'QueryAndPhysics',
true
)
TypeNameDefaultDescription
VectorLocationThe location to spawn the vehicle at.
RotatorRotationThe orentiation of the vehicle.
stringBlueprintAssetLong package name for the vehicle BP, e.g. "/Game/Vehicles/BP_MyCar.BP_MyCar_C"
stringCollisionTypeQueryAndPhysicsOne of "NoCollision", "QueryOnly", "PhysicsOnly", "QueryAndPhysics"
booleanGravityEnabledtrueWhether physics gravity is enabled

Functionsโ€‹

SetThrottleInputโ€‹

Sets the throttle input for the vehicle.

  • value: number โ€” throttle value, typically 0.0 or 1.0 (on/off)
Example
vehicle:SetThrottleInput(1.0) -- full throttle

SetSteeringInputโ€‹

Sets the steering input for the vehicle.

  • value: number โ€” steering input in range -1.0 (full left) to 1.0 (full right)
Example
vehicle:SetSteeringInput(-0.5) -- steer left

SetBrakeInputโ€‹

Sets the brake input for the vehicle.

  • value: number โ€” brake input in range 0.0 (no brake) to 1.0 (full brake)
Example
vehicle:SetBrakeInput(1.0) -- hard brake

SetHandBrakeInputโ€‹

Sets the handbrake state for the vehicle.

  • enabled: boolean โ€” true to enable handbrake, false to release
Example
vehicle:SetHandBrakeInput(true)

Hornโ€‹

Sets the horn state for the vehicle.

  • state: boolean โ€” true to honk, false to stop
Example
vehicle:Horn(true)

Engine Controlโ€‹

HoldStarterโ€‹

Holds the engine starter for a specified duration.

  • startTime: number โ€” time to hold the starter in seconds (default 0.0)
Example
vehicle:HoldStarter(0.5)

ReleaseStarterโ€‹

Releases the engine starter.

Example
vehicle:ReleaseStarter()

StopEngineโ€‹

Stops the engine.

Example
vehicle:StopEngine()

SetEngineHealthโ€‹

Sets the engine health.

  • health: number โ€” engine health value in range 0.0 (destroyed) to 1.0 (full)
Example
vehicle:SetEngineHealth(0.75)

GetEngineHealthโ€‹

Gets the engine/vehicle health.

  • returns: number|nil โ€” health in range 0.0 to 1.0, or nil if movement is missing
Example
local health = vehicle:GetEngineHealth() or 0.0

Fuel Systemโ€‹

AddFuelโ€‹

Adds fuel to the vehicleโ€™s current fuel level.

  • amount: number โ€” amount of fuel to add (use 0.0โ€“1.0 scale)
Example
vehicle:AddFuel(0.1)

SetFuelโ€‹

Sets the fuel level of the vehicle.

  • amount: number โ€” new fuel level in range 0.0 to 1.0
Example
vehicle:SetFuel(0.5)

GetFuelRatioโ€‹

Gets the current fuel ratio of the vehicle.

  • returns: number โ€” fuel level in range 0.0 to 1.0 (defaults to 0.0 if missing)
Example
local fuel = vehicle:GetFuelRatio()

State Queriesโ€‹

IsInReverseโ€‹

Returns if the vehicle is currently in reverse gear.

  • returns: boolean โ€” true if in reverse, otherwise false
Example
if vehicle:IsInReverse() then
-- show reverse icon
end

GetRPMRatioโ€‹

Gets the normalized engine RPM.

  • returns: number โ€” RPM ratio between 0.0 and 1.0
Example
local rpm = vehicle:GetRPMRatio()

GetNumberOfWheelsโ€‹

Returns the total number of wheels on the vehicle.

  • returns: integer โ€” wheel count
Example
print("Wheels:", vehicle:GetNumberOfWheels())

GetNumberOfWheelsTouchingGroundโ€‹

Returns how many wheels are currently touching the ground.

  • returns: integer โ€” number of wheels on ground
Example
local grounded = vehicle:GetNumberOfWheelsTouchingGround()

GetNumberOfDriveWheelsTouchingGroundโ€‹

Returns how many drive wheels are drive wheels and touching the ground.

  • returns: integer โ€” number of drive wheels on ground
Example
local drivenGrounded = vehicle:GetNumberOfDriveWheelsTouchingGround()

GetMassPerWheelโ€‹

Returns the mass per wheel.

  • returns: number โ€” mass per wheel
Example
local massPerWheel = vehicle:GetMassPerWheel()

IsBrakingโ€‹

Returns whether the vehicle is currently braking.

  • returns: boolean โ€” true if braking, otherwise false
Example
if vehicle:IsBraking() then
-- brake lights logic
end

Sleep & Airborneโ€‹

SetCanSleepโ€‹

Controls whether the vehicle is allowed to go to sleep (physics idle).

  • enabled: boolean โ€” true to allow sleeping, false to prevent
Example
vehicle:SetCanSleep(false)

SetSleepingโ€‹

Forces the vehicle into or out of sleeping state.

  • enabled: boolean โ€” true to force sleeping, false to wake
Example
vehicle:SetSleeping(true)

ApplyAirbornePhysicsโ€‹

Applies airborne physics behavior once (used when the vehicle is in the air).

Example
vehicle:ApplyAirbornePhysics()

Setup & Data Accessโ€‹

GetSetupโ€‹

Returns the vehicleโ€™s setup data.

  • returns: UModularVehicleData | nil โ€” setup data or nil
Example
local setup = vehicle:GetSetup()

Debugging & Utilitiesโ€‹

GetWheelsโ€‹

Returns the wheels on the vehicle.

  • returns: table โ€” array-like table of UModularWheel objects
Example
local wheels = vehicle:GetWheels()

UpdateComponentsโ€‹

Updates vehicle components with additional wheels.

  • additionalWheels: table โ€” array-like table of UModularWheel objects to add
Example
vehicle:UpdateComponents(extraWheels)

AI & Navigationโ€‹

RequestDirectMoveโ€‹

Requests a direct move towards a velocity (AI/navigation helper).

  • moveVelocity: Vector โ€” desired movement velocity
  • forceMaxSpeed: boolean โ€” true to force max speed, false to respect limits (default false)
Example
vehicle:RequestDirectMove(Vector(1000, 0, 0), false)

RequestPathMoveโ€‹

Requests movement through a new move input vector (AI/navigation helper).

  • inputVector: Vector โ€” movement input direction/magnitude
Example
vehicle:RequestPathMove(Vector(1, 0, 0))

StopActiveMovementโ€‹

Stops applying further movement (usually zeroes acceleration).

Example
vehicle:StopActiveMovement()

StopMovementKeepPathingโ€‹

Stops movement immediately but continues following the current navigation path.

Example
vehicle:StopMovementKeepPathing()

Replication & Cosmetic Syncโ€‹

SetCosmeticDataOnServerโ€‹

Sets replicated cosmetic data on the server.

  • data: FRepCosmeticData โ€” cosmetic data struct
Example
vehicle:SetCosmeticDataOnServer(cosmeticData)

Extra Nav Movement Helpersโ€‹

IsFlyingโ€‹

Whether the vehicle is considered flying.

  • returns: boolean โ€” true if flying
Example
if vehicle:IsFlying() then
-- airborne logic
end

IsFallingโ€‹

Whether the vehicle is falling.

  • returns: boolean โ€” true if falling
Example
if vehicle:IsFalling() then
-- falling logic
end

IsMovingOnGroundโ€‹

Whether the vehicle is moving on the ground.

  • returns: boolean โ€” true if moving on ground
Example
if vehicle:IsMovingOnGround() then
-- traction logic
end

IsSwimmingโ€‹

Whether the vehicle is swimming (moving through fluid).

  • returns: boolean โ€” true if swimming
Example
if vehicle:IsSwimming() then
-- water logic
end

IsCrouchingโ€‹

Whether the nav movement considers the vehicle โ€œcrouchingโ€ (rare for vehicles, but exposed).

  • returns: boolean โ€” true if crouching
Example
if vehicle:IsCrouching() then
-- low-profile logic
end

GetVelocityForNavMovementโ€‹

Gets the current velocity used by nav movement.

  • returns: Vector โ€” current nav velocity (defaults to Vector(0,0,0))
Example
local vel = vehicle:GetVelocityForNavMovement()

GetMaxSpeedForNavMovementโ€‹

Gets the maximum speed used for navigation.

  • returns: number โ€” max nav speed
Example
local maxSpeed = vehicle:GetMaxSpeedForNavMovement()

Lights & Sirensโ€‹

SetRightIndicatorโ€‹

Sets the right indicator/blinker state.

  • NewState: boolean โ€” true to enable, false to disable
Example
vehicle:SetRightIndicator(true)

SetLeftIndicatorโ€‹

Sets the left indicator/blinker state.

  • NewState: boolean โ€” true to enable, false to disable
Example
vehicle:SetLeftIndicator(true)

SetReverseLightโ€‹

Sets the reverse light state.

  • NewState: boolean โ€” true to enable, false to disable
Example
vehicle:SetReverseLight(true)

SetRedLightIntensityโ€‹

Sets the red light intensity (e.g. emergency light).

  • Value: number โ€” red light intensity
Example
vehicle:SetRedLightIntensity(5.0)

SetLightsEmissiveStrengthโ€‹

Sets overall light emissive strength.

  • Value: number โ€” emissive strength
Example
vehicle:SetLightsEmissiveStrength(3.0)

SetIndicatorLightsIntensityโ€‹

Sets indicator light intensity.

  • Value: number โ€” indicator light intensity
Example
vehicle:SetIndicatorLightsIntensity(4.0)

SetIndicatorAnimationSpeedโ€‹

Sets indicator blink animation speed.

  • Value: number โ€” animation speed
Example
vehicle:SetIndicatorAnimationSpeed(1.5)

SetHazardLightโ€‹

Sets the hazard lights state.

  • NewState: boolean โ€” true to enable hazards, false to disable
Example
vehicle:SetHazardLight(true)

SetBrakeLightโ€‹

Sets the brake light state manually.

  • NewState: boolean โ€” true to enable, false to disable
Example
vehicle:SetBrakeLight(true)

SetSirenStateโ€‹

Toggles the siren state if a siren component is present.

  • state: boolean โ€” true to enable siren, false to disable
Example
vehicle:SetSirenState(true)

SetSirenEmissionStrengthโ€‹

Sets siren light emission strength.

  • Amount: number โ€” emission strength
Example
vehicle:SetSirenEmissionStrength(2.0)

SetSirenRedColorโ€‹

Sets the siren red color.

  • NewColor: LinearColor โ€” new red color
Example
vehicle:SetSirenRedColor(LinearColor(1, 0, 0, 1))

SetSirenBlueColorโ€‹

Sets the siren blue color.

  • NewColor: LinearColor โ€” new blue color
Example
vehicle:SetSirenBlueColor(LinearColor(0, 0, 1, 1))

SetSirenBaseColorโ€‹

Sets the siren base color.

  • NewColor: LinearColor โ€” new base color
Example
vehicle:SetSirenBaseColor(LinearColor(1, 1, 1, 1))

SetSirenAnimationSpeedโ€‹

Sets the siren animation speed.

  • Speed: number โ€” animation speed multiplier
Example
vehicle:SetSirenAnimationSpeed(1.2)
โœจ