Jump to content

Cylinder marker rotation


Bishop_G

Recommended Posts

Posted
hello Community,
I want to make the marker like in GTA:SA.
As you know, the marker rotates around its own axis in GTA:SA.
setElementRotation does not work for the marker.
Which function can I use to rotate the marker from left to right?
I can use onClientRender as an event. But I don't know which function to use.
Can you help?
Posted

You can rotate it via setElementMatrix:
 

function setMarkerHeading(markerElement, rotationDegrees)
	local markerMatrix = getElementMatrix(markerElement)

	-- Convert degrees to radians
	rotationDegrees = math.rad(rotationDegrees)

	-- Rotate around Z axis
	local cosAngle = math.cos(rotationDegrees)
	local sinAngle = math.sin(rotationDegrees)

	markerMatrix[1][1] = cosAngle
	markerMatrix[1][2] = sinAngle
	markerMatrix[1][3] = 0

	markerMatrix[2][1] = -sinAngle
	markerMatrix[2][2] = cosAngle
	markerMatrix[2][3] = 0

	markerMatrix[3][1] = 0
	markerMatrix[3][2] = 0
	markerMatrix[3][3] = 1

	-- Apply updated matrix
	return setElementMatrix(markerElement, markerMatrix)
end

It's only rotates it around the Z axis like in Single-Player, if you want to rotate it in more axes you should search for rotation matrix in your preferred search engine.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...