Bishop_G Posted September 28, 2023 Share Posted September 28, 2023 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? Link to comment
Jayceon Posted September 28, 2023 Share Posted September 28, 2023 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. 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now