Jump to content

object is rotating to the oppsoite direction


Xwad

Recommended Posts

I made this script which creates a weapon and attach it to a vehicle. The weapon will rotate to that direction where the vehicle turret is looking at. The rx is rotating in the wrong direction! When the vehicles barrel Its rotating up then the weapon is rotatimg down, and when the barrel is rotating down then the weapon is rotating up:/ the rz is working correctly! heres the code. Thanks in advance!

client.lua

function rotate_object(veh) 
local veh = getPedOccupiedVehicle ( localPlayer ) 
  
local _,_,rz = getVehicleComponentRotation(veh, "misc_a") 
local rx,_,_ = getVehicleComponentRotation(veh, "misc_b") 
  
triggerServerEvent("rotate_object", localPlayer, veh,rx,rz, localPlayer) 
end  

server.lua

  
function rotate_object(veh,rx,rz) 
  
local object = getElementData ( veh, "object" ) 
local object2 = getElementData ( veh, "object2" ) 
  
local weapon = getElementData ( veh, "weapon" ) 
  
setElementAttachedOffsets ( object, 0, 0, 0, 0, 7, rz+95) 
setElementAttachedOffsets ( object2, 0.9, -0.6, 3, 0, rx+0, 0) --<--- this line 
setElementAttachedOffsets ( weapon, 0.9, -0.6, 3, rx+7, 0) 
end 
addEvent("rotate_object", true) 
addEventHandler("rotate_object", root, rotate_object) 
  

Edited by Guest
Link to comment
      
    function rotate_object(veh,rxa,rz) 
      
    local rx = -rxa 
    local object = getElementData ( veh, "object" ) 
    local object2 = getElementData ( veh, "object2" ) 
      
    local weapon = getElementData ( veh, "weapon" ) 
      
    setElementAttachedOffsets ( object, 0, 0, 0, 0, 7, rz+95) 
    setElementAttachedOffsets ( object2, 0.9, -0.6, 3, 0, rx+0, 0) --<--- this line 
    setElementAttachedOffsets ( weapon, 0.9, -0.6, 3, rx+7, 0) 
    end 
    addEvent("rotate_object", true) 
    addEventHandler("rotate_object", root, rotate_object) 
      

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