DarkLink Posted July 7, 2011 Posted July 7, 2011 Hey guys, I would be really nice if there was some function like this.. so I dont need to put manual markers on my map files. Is it possible to get the position 1 meter in front of any ped? I mean I want to place a marker in front of a ped.. not on his back!! in front, like u were buying something from him. Is there any function to get the position of that spot? Thanks!
Buffalo Posted July 7, 2011 Posted July 7, 2011 Proceed to getElementMatrix() There is fine examples of what you need. Only for peds and vehicles. And if in case you need to do it serverside function getPositionInFront(element,meters) local x, y, z = getElementPosition ( element ) local a,b,r = getVehicleRotation ( element ) x = x - math.sin ( math.rad(r) ) * meters y = y + math.cos ( math.rad(r) ) * meters return x,y,z end
DarkLink Posted July 7, 2011 Author Posted July 7, 2011 Proceed to getElementMatrix() There is fine examples of what you need. Only for peds and vehicles. And if in case you need to do it serverside function getPositionInFront(element,meters) local x, y, z = getElementPosition ( element ) local a,b,r = getVehicleRotation ( element ) x = x - math.sin ( math.rad(r) ) * meters y = y + math.cos ( math.rad(r) ) * meters return x,y,z end Hmm I understand I need some math calculations, and use Pythagorean theorem Didnt know about that, I will try that later, first need to fix the rotation problem. Thanks for your help mate!
DarkLink Posted July 7, 2011 Author Posted July 7, 2011 Buffalo I waas trying to understand your function, but need to know one thing, how map of gta is built ? I mean x, y, z .. y comes from south to north and x from west to east ? is that right? thanks.
Buffalo Posted July 7, 2011 Posted July 7, 2011 Yes, but bare in mind that if a coordinate is negative it will get inversed
DarkLink Posted July 7, 2011 Author Posted July 7, 2011 Yes, but bare in mind that if a coordinate is negative it will get inversed Hmm what do u mean? if an X is negative it will become positive? Btw I dont get it why you use subtraction on Y and addition on X. In my head would be addition for both but I might be wrong. Can you explain me? thanks. I understand this part " math.sin ( math.rad® ) * meters " you dont need to explain Thanks in advance!!
Buffalo Posted July 7, 2011 Posted July 7, 2011 Just take it into account that coord values can be negative ^^ Try to subtract both values, so from the result you'll imagine easier how its working.
DarkLink Posted July 7, 2011 Author Posted July 7, 2011 Just take it into account that coord values can be negative ^^Try to subtract both values, so from the result you'll imagine easier how its working. Yees! I found out why the substraction on Y!! Because we need to use sin there, and sin is negative between 180 degrees and 360 degrees, right ? Thanks buffalo!
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