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.
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
)
| Type | Name | Default | Description |
|---|---|---|---|
| Vector | Location |
The location to spawn the vehicle at. | |
| Rotator | Rotation |
The orentiation of the vehicle. | |
| string | BlueprintAsset |
Long package name for the vehicle BP, e.g. "/Game/Vehicles/BP_MyCar.BP_MyCar_C" | |
| string | CollisionType |
QueryAndPhysics |
One of "NoCollision", "QueryOnly", "PhysicsOnly", "QueryAndPhysics" |
| boolean | GravityEnabled |
true |
Whether physics gravity is enabled |
Functions#
SetThrottleInput#
Sets the throttle input for the vehicle.
- value:
number— throttle value, typically0.0or1.0(on/off)
vehicle:SetThrottleInput(1.0) -- full throttle
SetSteeringInput#
Sets the steering input for the vehicle.
- value:
number— steering input in range-1.0(full left) to1.0(full right)
vehicle:SetSteeringInput(-0.5) -- steer left
SetBrakeInput#
Sets the brake input for the vehicle.
- value:
number— brake input in range0.0(no brake) to1.0(full brake)
vehicle:SetBrakeInput(1.0) -- hard brake
SetHandBrakeInput#
Sets the handbrake state for the vehicle.
- enabled:
boolean—trueto enable handbrake,falseto release
vehicle:SetHandBrakeInput(true)
Horn#
Sets the horn state for the vehicle.
- state:
boolean—trueto honk,falseto stop
vehicle:Horn(true)
Engine Control#
HoldStarter#
Holds the engine starter for a specified duration.
- startTime:
number— time to hold the starter in seconds (default0.0)
vehicle:HoldStarter(0.5)
ReleaseStarter#
Releases the engine starter.
vehicle:ReleaseStarter()
StopEngine#
Stops the engine.
vehicle:StopEngine()
SetEngineHealth#
Sets the engine health.
health: number— engine health value in range0.0(destroyed) to1.0(full)
vehicle:SetEngineHealth(0.75)
GetEngineHealth#
Gets the engine/vehicle health.
- returns:
number|nil— health in range0.0to1.0, ornilif movement is missing
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 (use0.0–1.0scale)
vehicle:AddFuel(0.1)
SetFuel#
Sets the fuel level of the vehicle.
amount: number— new fuel level in range0.0to1.0
vehicle:SetFuel(0.5)
GetFuelRatio#
Gets the current fuel ratio of the vehicle.
- returns:
number— fuel level in range0.0to1.0(defaults to0.0if missing)
local fuel = vehicle:GetFuelRatio()
State Queries#
IsInReverse#
Returns if the vehicle is currently in reverse gear.
- returns:
boolean—trueif in reverse, otherwisefalse
if vehicle:IsInReverse() then
-- show reverse icon
end
GetRPMRatio#
Gets the normalized engine RPM.
- returns:
number— RPM ratio between0.0and1.0
local rpm = vehicle:GetRPMRatio()
GetNumberOfWheels#
Returns the total number of wheels on the vehicle.
- returns:
integer— wheel count
print("Wheels:", vehicle:GetNumberOfWheels())
GetNumberOfWheelsTouchingGround#
Returns how many wheels are currently touching the ground.
- returns:
integer— number of wheels on ground
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
local drivenGrounded = vehicle:GetNumberOfDriveWheelsTouchingGround()
GetMassPerWheel#
Returns the mass per wheel.
- returns:
number— mass per wheel
local massPerWheel = vehicle:GetMassPerWheel()
IsBraking#
Returns whether the vehicle is currently braking.
- returns:
boolean—trueif braking, otherwisefalse
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—trueto allow sleeping,falseto prevent
vehicle:SetCanSleep(false)
SetSleeping#
Forces the vehicle into or out of sleeping state.
- enabled:
boolean—trueto force sleeping,falseto wake
vehicle:SetSleeping(true)
ApplyAirbornePhysics#
Applies airborne physics behavior once (used when the vehicle is in the air).
vehicle:ApplyAirbornePhysics()
Setup & Data Access#
GetSetup#
Returns the vehicle’s setup data.
- returns:
UModularVehicleData | nil— setup data ornil
local setup = vehicle:GetSetup()
Debugging & Utilities#
GetWheels#
Returns the wheels on the vehicle.
- returns:
table— array-like table ofUModularWheelobjects
local wheels = vehicle:GetWheels()
UpdateComponents#
Updates vehicle components with additional wheels.
- additionalWheels:
table— array-like table ofUModularWheelobjects to add
vehicle:UpdateComponents(extraWheels)
AI & Navigation#
RequestDirectMove#
Requests a direct move towards a velocity (AI/navigation helper).
- moveVelocity:
Vector— desired movement velocity - forceMaxSpeed:
boolean—trueto force max speed,falseto respect limits (defaultfalse)
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
vehicle:RequestPathMove(Vector(1, 0, 0))
StopActiveMovement#
Stops applying further movement (usually zeroes acceleration).
vehicle:StopActiveMovement()
StopMovementKeepPathing#
Stops movement immediately but continues following the current navigation path.
vehicle:StopMovementKeepPathing()
Replication & Cosmetic Sync#
SetCosmeticDataOnServer#
Sets replicated cosmetic data on the server.
- data:
FRepCosmeticData— cosmetic data struct
vehicle:SetCosmeticDataOnServer(cosmeticData)
Extra Nav Movement Helpers#
IsFlying#
Whether the vehicle is considered flying.
- returns:
boolean—trueif flying
if vehicle:IsFlying() then
-- airborne logic
end
IsFalling#
Whether the vehicle is falling.
- returns:
boolean—trueif falling
if vehicle:IsFalling() then
-- falling logic
end
IsMovingOnGround#
Whether the vehicle is moving on the ground.
- returns:
boolean—trueif moving on ground
if vehicle:IsMovingOnGround() then
-- traction logic
end
IsSwimming#
Whether the vehicle is swimming (moving through fluid).
- returns:
boolean—trueif swimming
if vehicle:IsSwimming() then
-- water logic
end
IsCrouching#
Whether the nav movement considers the vehicle “crouching” (rare for vehicles, but exposed).
- returns:
boolean—trueif crouching
if vehicle:IsCrouching() then
-- low-profile logic
end
GetVelocityForNavMovement#
Gets the current velocity used by nav movement.
- returns:
Vector— current nav velocity (defaults toVector(0,0,0))
local vel = vehicle:GetVelocityForNavMovement()
GetMaxSpeedForNavMovement#
Gets the maximum speed used for navigation.
- returns:
number— max nav speed
local maxSpeed = vehicle:GetMaxSpeedForNavMovement()
Lights & Sirens#
SetRightIndicator#
Sets the right indicator/blinker state.
NewState: boolean—trueto enable,falseto disable
vehicle:SetRightIndicator(true)
SetLeftIndicator#
Sets the left indicator/blinker state.
NewState: boolean—trueto enable,falseto disable
vehicle:SetLeftIndicator(true)
SetReverseLight#
Sets the reverse light state.
NewState: boolean—trueto enable,falseto disable
vehicle:SetReverseLight(true)
SetRedLightIntensity#
Sets the red light intensity (e.g. emergency light).
- Value:
number— red light intensity
vehicle:SetRedLightIntensity(5.0)
SetLightsEmissiveStrength#
Sets overall light emissive strength.
- Value:
number— emissive strength
vehicle:SetLightsEmissiveStrength(3.0)
SetIndicatorLightsIntensity#
Sets indicator light intensity.
- Value:
number— indicator light intensity
vehicle:SetIndicatorLightsIntensity(4.0)
SetIndicatorAnimationSpeed#
Sets indicator blink animation speed.
- Value:
number— animation speed
vehicle:SetIndicatorAnimationSpeed(1.5)
SetHazardLight#
Sets the hazard lights state.
- NewState:
boolean—trueto enable hazards,falseto disable
vehicle:SetHazardLight(true)
SetBrakeLight#
Sets the brake light state manually.
NewState: boolean—trueto enable,falseto disable
vehicle:SetBrakeLight(true)
SetSirenState#
Toggles the siren state if a siren component is present.
state: boolean—trueto enable siren,falseto disable
vehicle:SetSirenState(true)
SetSirenEmissionStrength#
Sets siren light emission strength.
Amount: number— emission strength
vehicle:SetSirenEmissionStrength(2.0)
SetSirenRedColor#
Sets the siren red color.
- NewColor:
LinearColor— new red color
vehicle:SetSirenRedColor(LinearColor(1, 0, 0, 1))
SetSirenBlueColor#
Sets the siren blue color.
- NewColor:
LinearColor— new blue color
vehicle:SetSirenBlueColor(LinearColor(0, 0, 1, 1))
SetSirenBaseColor#
Sets the siren base color.
- NewColor:
LinearColor— new base color
vehicle:SetSirenBaseColor(LinearColor(1, 1, 1, 1))
SetSirenAnimationSpeed#
Sets the siren animation speed.
- Speed:
number— animation speed multiplier
vehicle:SetSirenAnimationSpeed(1.2)