Jump to content

[Help]Attached object rotation problem


XboxMS

Recommended Posts

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  

show.jpg?lgfp=3000

if there is any way to calculate the z rotation of the object in world space please help :roll:

sorry for my bad English :oops::oops:

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