SetVehicleAngularVelocity: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function VehicleVelocityReset(player) | |||
local vehicle = GetPlayerVehicle(player) | |||
if (vehicle ~= 0) then | |||
SetVehicleLinearVelocity(vehicle, 0.0, 0.0, 0.0, true) | |||
SetVehicleAngularVelocity(vehicle, 0.0, 0.0, 0.0, true) | |||
local rx, ry, rz = GetVehicleRotation(vehicle) | |||
-- Reset pitch and roll, leave yaw alone | |||
SetVehicleRotation(vehicle, 0.0, ry, 0.0) | |||
end | |||
end | |||
AddRemoteEvent("VehicleVelocityReset", VehicleVelocityReset) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{VehicleFunctions}} | {{VehicleFunctions}} |
Latest revision as of 19:32, 30 August 2020
Description
Set the vehicle's angular (rotational) velocity.
Syntax
SetVehicleAngularVelocity(vehicle, x, y, z [, reset])
Parameters
- vehicle
The vehicle identifier. - x
The X axis velocity - y
The Y axis velocity - z
The Z axis velocity - reset (optional)
true to reset the angular velocity, default: false
Return Value
- This function returns true.
Example
function VehicleVelocityReset(player)
local vehicle = GetPlayerVehicle(player)
if (vehicle ~= 0) then
SetVehicleLinearVelocity(vehicle, 0.0, 0.0, 0.0, true)
SetVehicleAngularVelocity(vehicle, 0.0, 0.0, 0.0, true)
local rx, ry, rz = GetVehicleRotation(vehicle)
-- Reset pitch and roll, leave yaw alone
SetVehicleRotation(vehicle, 0.0, ry, 0.0)
end
end
AddRemoteEvent("VehicleVelocityReset", VehicleVelocityReset)
See also
- CreateVehicle
- DestroyVehicle
- IsValidVehicle
- GetVehicleCount
- GetAllVehicles
- GetVehicleModel
- GetVehicleModelName
- SetVehicleRespawnParams
- IsVehicleStreamedIn
- GetStreamedVehiclesForPlayer
- GetStreamedVehicles
- SetVehicleLocation
- GetVehicleLocation
- SetVehicleRotation
- GetVehicleRotation
- SetVehicleHeading
- GetVehicleHeading
- SetVehicleHealth
- GetVehicleHealth
- SetVehicleLicensePlate
- GetVehicleVelocity
- GetVehicleDriver
- GetVehiclePassenger
- GetVehicleNumberOfSeats
- SetVehicleColor
- GetVehicleColor
- SetVehicleLinearVelocity
- SetVehicleAngularVelocity
- GetVehicleGear
- SetVehicleHoodRatio
- GetVehicleHoodRatio
- SetVehicleTrunkRatio
- GetVehicleTrunkRatio
- StartVehicleEngine
- StopVehicleEngine
- GetVehicleEngineState
- SetVehicleLightEnabled
- GetVehicleLightState
- SetVehicleDamage
- GetVehicleDamage
- AttachVehicleNitro