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)