Drakath Posted February 12, 2015 Posted February 12, 2015 What's the magic formula to make a ped look at localPlayer with setElementRotation?
Drakath Posted February 12, 2015 Author Posted February 12, 2015 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
Mr_Moose Posted February 12, 2015 Posted February 12, 2015 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.
Drakath Posted February 12, 2015 Author Posted February 12, 2015 Thanks for posting the obvious part but can you apply the mathematical functions to those arguments?
Mr_Moose Posted February 12, 2015 Posted February 12, 2015 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.
Drakath Posted February 12, 2015 Author Posted February 12, 2015 Thanks, I didn't notice any changes in my pedestrians but I guess my script is more efficient now.
Mr_Moose Posted February 12, 2015 Posted February 12, 2015 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.
JR10 Posted February 12, 2015 Posted February 12, 2015 If this is still not resolved then you might want to look at this useful function: https://wiki.multitheftauto.com/wiki/FindRotation
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