Jump to content

Calculate world position of vehicle components


Recommended Posts

Hello community, i try to calculate the world position of the turret of the Rhino tank. I found this code on the web, but it does return wrong positions (at least X position is wrong), my tank is at x,y,z = 0,0,0 and this returns x=3 for the turret. Can someone tell me whats wrong?

I tried to get the positions with getVehicleComponentPosition but this function is bugged and it returns wrong positions for turret and misc_c components so i used x,y,z = 0,0,1.1 for testing this code.

function getComponentWorldPosition(vehicle, component) 
    local m = getElementMatrix(vehicle) 
    local x, y, z = getVehicleComponentPosition(vehicle, component) 
     
    -- Vektor mit ElementMatrix multiplizieren 
    local wX = x * m[1][1] + y * m[2][1] + z * m[3][1] + m[4][1] 
    local wY = x * m[1][2] + y * m[2][2] + z * m[3][2] + m[4][2] 
    local wY = x * m[1][3] + y * m[2][3] + z * m[3][3] + m[4][3] 
    return wX, wY, wZ 
end 

Link to comment

I'm sorry, but this function IS bugged. Try to get the position of misc_c or the turret and you will see, that those are completely wrong and this has been reported at bugs.mtasa.com. Maybe the wrong turret position is caused by modified Rhino.dff models, i will test it with an unmodified model soon, but misc_c is surely wrong even with unmodified game files.

Also, i dont want any turret rotation. I want to get the world xyz of misc_a and misc_c.

Link to comment

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