Jump to content

How to rotate the weapon on the vehicle


Andrew75t

Recommended Posts

Hello all.
help me please to implement the rotation of the minigun by 40 degrees.
I want the minigun to look forward and can to turn 20 degrees to the left and 20 degrees to the right. Now it can rotate the minigun 180 degrees around its axis, but I'm not sure what is right, help me to limit the rotation of the machine gun. 

this is the part of the code for rotate the minigun 180 degrees:

local aimSensitivity = 30;  
function rotateGun_Handler(cX, cY, aX, aY, wX, wY, wZ) 
    local oX, oY, oZ, oRX, oRY, oRZ = getElementRotation (weapon); 
   
    if (oRZ-((cX-0.5)*aimSensitivity) > 30 or oRZ-((cX-0.5)*aimSensitivity) < 80) then
        oRZ = oRZ-((cX-0.5)*aimSensitivity); 
    end 
    setCameraTarget(weapon,localPlayer) 
    setElementAttachedOffsets(weapon, oX, oY, oZ, oRX, oRY, oRZ); 
    setCursorPosition(screenW/2, screenH/2); 
end 
addEventHandler( "onClientCursorMove", getRootElement( ), rotateGun_Handler)

 

Link to comment

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...