Atton Posted April 30, 2014 Share Posted April 30, 2014 I want to ask how would it be possible to get the position say in front of a car. Link to comment
Karuzo Posted April 30, 2014 Share Posted April 30, 2014 https://wiki.multitheftauto.com/wiki/Ge ... enPoints3D Link to comment
Moderators IIYAMA Posted April 30, 2014 Moderators Share Posted April 30, 2014 https://wiki.multitheftauto.com/wiki/GetElementMatrix function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end -- Get the position of a point 2 units in front of the element: x,y,z = getPositionFromElementOffset(element,0,2,0) Link to comment
denny199 Posted April 30, 2014 Share Posted April 30, 2014 IIYAMA code works only client side (getElementMatrix) This function works client side & server side, I didn't made it but JR10 posted it once. function getPositionInfrontOfElement ( element , meters ) if not element or not isElement ( element ) then return false end if not meters then meters = 3 end local posX , posY , posZ = getElementPosition ( element ) local _ , _ , rotation = getElementRotation ( element ) posX = posX - math.sin ( math.rad ( rotation ) ) * meters posY = posY + math.cos ( math.rad ( rotation ) ) * meters return posX , posY , posZ end Usage: local x,y,z = getPositionInfrontOfElement ( element , meters ) element = the element's position you want to get in front off meters = how many units from the element it needs to check Link to comment
Moderators IIYAMA Posted April 30, 2014 Moderators Share Posted April 30, 2014 @Denny there is also an example at the same page which also can give the matrix at serverside. (Example 3) https://wiki.multitheftauto.com/wiki/GetElementMatrix 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