Vehicles
HELIX uses the HVehicle class to handle all drivable vehicles -- cars, trucks, boats, you name it. The system handles physics, engine simulation, fuel, and lighting so you can focus on building great driving experiences.
Spawning a Vehicle
Drop a vehicle into your world by creating a new HVehicle instance with a position, rotation, and Blueprint asset reference.
- Blueprint
- Lua
- JavaScript
// Spawn a vehicle at a specific location
AHVehicle* MyCar = HVehicle::Spawn(
FVector(1000, 0, 50),
FRotator(0, 90, 0),
"/Game/Vehicles/BP_Sedan.BP_Sedan_C"
);
-- Spawn a vehicle at a specific location
local my_car = HVehicle(
Vector(1000, 0, 50),
Rotator(0, 90, 0),
"/Game/Vehicles/BP_Sedan.BP_Sedan_C"
)
// Spawn a vehicle at a specific location
const myCar = new HVehicle(
new Vector(1000, 0, 50),
new Rotator(0, 90, 0),
"/Game/Vehicles/BP_Sedan.BP_Sedan_C"
);
Driving Controls
HVehicle exposes direct input controls for throttle, steering, braking, and the handbrake. You can also manage the engine lifecycle and fuel system.
- Blueprint
- Lua
- JavaScript
// Apply full throttle and steer left
MyCar->SetThrottleInput(1.0f);
MyCar->SetSteeringInput(-0.5f);
// Apply brakes
MyCar->SetBrakeInput(1.0f);
// Engage handbrake
MyCar->SetHandBrakeInput(true);
-- Apply full throttle and steer left
my_car:SetThrottleInput(1.0)
my_car:SetSteeringInput(-0.5)
-- Apply brakes
my_car:SetBrakeInput(1.0)
-- Engage handbrake
my_car:SetHandBrakeInput(true)
// Apply full throttle and steer left
myCar.SetThrottleInput(1.0);
myCar.SetSteeringInput(-0.5);
// Apply brakes
myCar.SetBrakeInput(1.0);
// Engage handbrake
myCar.SetHandBrakeInput(true);
Steering input ranges from -1.0 (full left) to 1.0 (full right). Throttle and brake range from 0.0 to 1.0.
Fuel & Engine
HVehicle includes a fuel system and engine lifecycle controls. You can set fuel levels, start and stop the engine, and monitor engine health.
- Blueprint
- Lua
- JavaScript
// Set fuel to full
MyCar->SetFuel(1.0f);
// Start the engine
MyCar->HoldStarter(0.5f);
MyCar->ReleaseStarter();
// Check engine health
float Health = MyCar->GetEngineHealth();
-- Set fuel to full
my_car:SetFuel(1.0)
-- Start the engine
my_car:HoldStarter(0.5)
my_car:ReleaseStarter()
-- Check engine health
local health = my_car:GetEngineHealth()
// Set fuel to full
myCar.SetFuel(1.0);
// Start the engine
myCar.HoldStarter(0.5);
myCar.ReleaseStarter();
// Check engine health
const health = myCar.GetEngineHealth();
Lights & Sirens
HVehicle provides fine-grained control over vehicle lighting, including indicators, brake lights, hazard lights, and sirens for emergency vehicles.
- Blueprint
- Lua
- JavaScript
// Turn on hazard lights
MyCar->SetHazardLight(true);
// Enable siren for emergency vehicles
MyCar->SetSirenState(true);
// Turn on left indicator
MyCar->SetLeftIndicator(true);
-- Turn on hazard lights
my_car:SetHazardLight(true)
-- Enable siren for emergency vehicles
my_car:SetSirenState(true)
-- Turn on left indicator
my_car:SetLeftIndicator(true)
// Turn on hazard lights
myCar.SetHazardLight(true);
// Enable siren for emergency vehicles
myCar.SetSirenState(true);
// Turn on left indicator
myCar.SetLeftIndicator(true);
You can find a variety of ready-to-use vehicle assets in the Vault, or import your own custom meshes with custom seat and door configurations.