XboxMS Posted April 20, 2015 Share Posted April 20, 2015 Hi i have a problem when i attach my custom object with a custom vehicle to make 14.5mm machine gun script every thing worked very well and like i want but i had one problem when i used player's camera rotation to rotate the object like i know when i rotate the attached element it rotates in ToAttachedElement's space not the world space the problem is the rotation at z axis which means it will rotate successfully only if the vehicle's z rotation is 0 i think the picture and the code will explain more function updateWeaponAndObj (_,_,_,_,worldx,worldy,worldz) -- added by another function ( "onClientCursorMove" ) local x,y,z = getElementPosition(weaponsobj)--the object local veh = getWeaponVehicle() -- it's get the vehicle by data local _,_,vehr = getElementRotation(veh) local rotationY = 0 local rotationZ = -getPedCameraRotation(localPlayer) local rotationX = (getCameraRotation ())+270 -- +270 because there is a problem with the custom object model file setElementAttachedOffsets(weaponsobj,0,-2.26,1.1, rotationX,rotationY,rotationZ) local _,_,rotz = getElementRotation(weaponsobj)-- i use it to rotate the player in the serverside triggerServerEvent("onClientMoveWeaponWe",localPlayer,rotz,x,y,z,rotationX,rotationY,rotationZ,worldx,worldy,worldz) end if there is any way to calculate the z rotation of the object in world space please help sorry for my bad English Link to comment
XboxMS Posted April 20, 2015 Author Share Posted April 20, 2015 i fixed the problem and it work now anyone maybe need it local rotationZ = -getPedCameraRotation(localPlayer)-vehr 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