- Documentation
- Server functions
- setVehicleComponentPosition
Function
setVehicleComponentPosition
Stores an offset for a named part of a vehicle model (e.g. the bonnet) relative to its position in the model.
Syntax
bool setVehicleComponentPosition(vehicle vehicle, string component, float x [, float y = 0, float z = 0])Arguments
vehiclevehicle- The vehicle.
componentstring- Part name.
xfloat- Offset to the right (m). A vector can be passed instead of three numbers.
yfloat, optional = 0- Offset forwards (m).
zfloat, optional = 0- Offset upwards (m).
Differences from MTA:SA
- These MTA:SA arguments are not here:
string base = "root"
In MTA:SA
setVehicleComponentPosition(vehicle theVehicle, string theComponent, float posX, float posY, float posZ, string base = "root")Returns
true on success.
Example
local vehicle = createVehicle(411, 2000, -1690, 13.5)
setVehicleComponentPosition(vehicle, "bonnet_dummy", 0, 0.1, 0.2)
Notes
State for scripts. Today the game applies only part visibility (setVehicleComponentVisible); part position, rotation and scale are stored, but the model does not change.
See also
getVehicleComponentPositionReturns the part offset stored withsetVehicleComponentPosition(0, 0, 0 when not set).resetVehicleComponentPositionClears the part offset stored withsetVehicleComponentPosition.setVehicleComponentTransformStores the position, rotation and scale of a model part in one call. Each of the three arguments is a vector or a{ x, y, z }table; an omitted one (nil) stays unchanged.