Jump to content

camera rotation


Xwad

Recommended Posts

Hi i made a script that makes possible if a player rotate his camera then the weapon will rotate to the same direction. I have only one problem.. the weapon is only rotating to left and right. Its not rotating up and down:/ i mean, forexample if i rotate the camera to the right or to the left then the weapon will rotate to the same direction. But when i look up and down then the weapon is not rotating up and down. Pls help

  
local test = createWeapon("m4", -2388.41,-581.15, 132.3)setWeaponState(test, "ready") 
  
  
  
function rotate () 
setElementRotation(test, 0, 3.2, 96.7 -getPedCameraRotation(localPlayer)) 
end 
addEventHandler ("onClientRender", root, rotate) 
  
  
  
  
  
 function findRotation( x1, y1, x2, y2 )    local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )    return t < 0 and t            + 360 or tend 
  

Link to comment
Hi i made a script that makes possible if a player rotate his camera then the weapon will rotate to the same direction. I have only one problem.. the weapon is only rotating to left and right. Its not rotating up and down:/ i mean, forexample if i rotate the camera to the right or to the left then the weapon will rotate to the same direction. But when i look up and down then the weapon is not rotating up and down. Pls help
  
local test = createWeapon("m4", -2388.41,-581.15, 132.3)setWeaponState(test, "ready") 
  
  
  
function rotate () 
setElementRotation(test, 0, 3.2, 96.7 -getPedCameraRotation(localPlayer)) 
end 
addEventHandler ("onClientRender", root, rotate) 
  
  
  
  
  
 function findRotation( x1, y1, x2, y2 )    local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )    return t < 0 and t            + 360 or tend 
  

You're just rotating Z-axis, that's why it's moving to right and left only.

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