Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/08/22 in all areas

  1. Hi. I've put together a code for you in which the door movement works as expected, there is one up and down movement involved at a certain camera/vehicle angle (see the pictures below). If you don't need that up/down movement either, we can remove it. local cameraElement = getCamera() local oldCursorRelX = 0.5 local oldCursorRelY = 0.5 local moveSensitivity = 2 function moveDoor(cursorRelX, cursorRelY) if not isCursorShowing() then return end local vehicleElement = getPedOccupiedVehicle(localPlayer) if not isElement(vehicleElement) then return end local cameraMatrix = getElementMatrix(cameraElement) local vehicleMatrix = getElementMatrix(vehicleElement) local dotProductX = cameraMatrix[1][1] * vehicleMatrix[1][1] + cameraMatrix[1][2] * vehicleMatrix[1][2] local dotProductY = cameraMatrix[3][1] * vehicleMatrix[1][1] + cameraMatrix[3][2] * vehicleMatrix[1][2] local cursorDeltaX = (cursorRelX - oldCursorRelX) * moveSensitivity local cursorDeltaY = (cursorRelY - oldCursorRelY) * moveSensitivity oldCursorRelX = cursorRelX oldCursorRelY = cursorRelY local dotProductCombined = cursorDeltaX * -dotProductX + cursorDeltaY * dotProductY local openRatio = getVehicleDoorOpenRatio(vehicleElement, 2) + dotProductCombined if openRatio < 0 then openRatio = 0 elseif openRatio > 1 then openRatio = 1 end setVehicleDoorOpenRatio(vehicleElement, 2, openRatio) end bindKey("f1", "down", function () addEventHandler("onClientCursorMove", root, moveDoor) end ) bindKey("f2", "down", function () removeEventHandler("onClientCursorMove", root, moveDoor) end )
    1 point
×
×
  • Create New...