SetVehicleAngularVelocity: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetVehicleAngularVelocity(vehicle, x, y, z [, reset])}} {{FuncParameters}} {{FuncParam|vehicle|__E..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Set the vehicle's angular (rotational) velocity.}}


{{FuncSyntax|SetVehicleAngularVelocity(vehicle, x, y, z [, reset])}}
{{FuncSyntax|SetVehicleAngularVelocity(vehicle, x, y, z [, reset])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|vehicle|__EDIT_ME__}}
{{FuncParam|vehicle|The vehicle identifier.}}
{{FuncParam|x|__EDIT_ME__}}
{{FuncParam|x|The X axis velocity}}
{{FuncParam|y|__EDIT_ME__}}
{{FuncParam|y|The Y axis velocity}}
{{FuncParam|z |__EDIT_ME__}}
{{FuncParam|z|The Z axis velocity}}
{{FuncParamOptional|reset|__EDIT_ME__}}
{{FuncParamOptional|reset|'''true''' to reset the angular velocity, default: '''false'''}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|This function returns '''true'''.}}


== Example ==
== Example ==
__EDIT_ME__
<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}}
__EDIT_ME__
{{VehicleFunctions}}

Latest revision as of 19:32, 30 August 2020

SetVehicleAngularVelocity

Type: Function
Context: Server
Introduced: v1.0

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