Xwad Posted April 13, 2016 Share Posted April 13, 2016 (edited) 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 April 14, 2016 by Guest Link to comment
Captain Cody Posted April 13, 2016 Share Posted April 13, 2016 You could always just set it as a negative to reverse the effect. Link to comment
Xwad Posted April 14, 2016 Author Share Posted April 14, 2016 How , where, what? You mean set the rx to rx=math.deg(-rx) ? Becaouse when i tried that than it was rotating to the good direction but it was rotating very fast. Link to comment
Captain Cody Posted April 14, 2016 Share Posted April 14, 2016 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
Xwad Posted April 14, 2016 Author Share Posted April 14, 2016 Its working now! really thanks 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