Jump to content

setElementRotation


Drakath

Recommended Posts

Start by looking at the syntax:

setPedRotation( thePed, z ) 
setElementRotation( thePed, x, y, z ) 

You need to provide x and y rotations as well which logically should be the same as they where before you changed the z rotation, so to get x and y, simply use:

local rx,ry,rz = getElementRotation( thePed ) 

Argument 1 and 4 will be the same as 1 and 2 in setPedRotation while 2 and 3 will get the values from rx and ry.

Link to comment

How hard could it be, you already posted the old working code, you need to write this:

setPedRotation(ped, (360 - math.deg(math.atan2((x - px), (y - py)))) % 360) 

as:

local rx,ry,rz = getElementRotation( ped ) 
setElementRotation(ped, rx, ry, (360 - math.deg(math.atan2((x - px), (y - py)))) % 360) 

Keep the rest of the code as it is, I assume that x,px,y,py are position coordinates.

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