SetVehicleRotation: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 6: Line 6:


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|vehicle|The vehicle rotation}}
{{FuncParam|vehicle|The vehicle identifier}}
{{FuncParam|x|The X axis}}
{{FuncParam|x|The pitch rotation}}
{{FuncParam|y|The Y axis}}
{{FuncParam|y|The yaw rotation}}
{{FuncParam|z|The Z axis}}
{{FuncParam|z|The roll rotation}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns '''true''' on success.}}


== 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}}
{{Template:VehicleFunctions}}
{{Template:VehicleFunctions}}

Latest revision as of 20:28, 30 August 2020

SetVehicleRotation

Type: Function
Context: Server
Introduced: v1.0

Description

Sets the vehicle rotation.

Syntax

SetVehicleRotation(vehicle, x, y, z)

Parameters

  • vehicle
    The vehicle identifier
  • x
    The pitch rotation
  • y
    The yaw rotation
  • z
    The roll rotation

Return Value

  • Returns true on success.

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