Mr.Loki Posted December 22, 2016 Share Posted December 22, 2016 Hi guys, I'm working on my Spiderman script and was wondering if anyone knew how to rotate an object to always look at a position. Been trying to make the player lean with the web but no luck at all. Link to comment
Arran Posted December 23, 2016 Share Posted December 23, 2016 I use this to make prisoner always face cop: local copX, copY, copZ = getElementPosition(cop) local prisonerX, prisonerY, prisonerZ = getElementPosition(prisoner) local copAngle = ( 360 - math.deg(math.atan2((copX - prisonerX), (copY - prisonerY))) ) % 360 You should be able to use this, copAngle is the Z rotation that you can set on the object so that it faces copX, copY, copZ but if you want it to also look up and down then you can probably clone line 3 from above and play around with copX, prisonerX, copY, prisonerY to get a combination that returns the X and Y rotation for the object. Link to comment
Mr.Loki Posted December 24, 2016 Author Share Posted December 24, 2016 @Arran This is what i have been using but the player seems to be rotating uncontrollably when using x,y,z. https://streamable.com/kpedz Link to comment
Arran Posted December 24, 2016 Share Posted December 24, 2016 Then you'll need to add some debug, the video shows on screen XYZ which is a good start, below that you should add the Z rotation so you can see what rotation it's setting on your ped, because the script might be correct but there's a GTA or MTA bug that makes it appear wrong. Link to comment
Mr.Loki Posted December 24, 2016 Author Share Posted December 24, 2016 Those XYZ values on the screen are the rotations that are being set. The problem was the z was using the y values so its fixed now. The main problem I'm getting now is I've set the z rotation to the camera so the player is always facing forward. When the Z rotation is 180 the X and Y rotations are ok but when the Z is 0 the rotations on X and Y are reversed. https://streamable.com/0n6sh In this video I reversed the Y rotation so that the X and Y are correct when the Z rotation is 180. https://streamable.com/62o0o Link to comment
Mr.Loki Posted December 27, 2016 Author Share Posted December 27, 2016 Does anyone know how to offset the X and Y so its relative to the Z? Link to comment
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