Jump to content

setElementRotation


Drakath

Recommended Posts

Posted
Try to use :
setCameraMatrix() 

You did not understood me.

This makes a ped look at you: setPedRotation(ped, (360 - math.deg(math.atan2((x - px), (y - py)))) % 360)

I want the same result using setElementRotation

Posted

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.

Posted

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.

Posted

The main reason to upgrade is because the old function setPedRotation is deprecated, that means it'll be removed in future versions. You'll do this change mainly to prevent your resources from stop working after a future update that removes the old function.

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