1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.30 Bug Reporting thread
    Solutions and more information may already be available.

How to get vehicle roll, pitch, yaw?

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by Meriel, Apr 14, 2021.

  1. Meriel

    Meriel
    Expand Collapse

    Joined:
    Apr 9, 2021
    Messages:
    4
    How do I get the vehicle roll, pitch and yaw? I can retrieve vehicle pos, dir, up, and front but currently have no way to convert it into a meaningful set of Euler angles.
     
  2. Geraldo_o_geral

    Geraldo_o_geral
    Expand Collapse

    Joined:
    Jan 30, 2021
    Messages:
    211
    go on ui and select what you want

    i think you are asking this

    press 'esc' and click here
    upload_2021-4-14_18-11-1.png
    click in '+'
    upload_2021-4-14_18-11-43.png
    select what you want
    upload_2021-4-14_18-12-25.png
    put it where you want in the screen
    upload_2021-4-14_18-13-37.png
    and then press '✓'
    upload_2021-4-14_18-15-7.png

    hope this helps
     
  3. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Here you go (its in radians):
    Code:
    local roll, pitch, yaw = obj:getRollPitchYaw()
     
    • Like Like x 1
  4. Geraldo_o_geral

    Geraldo_o_geral
    Expand Collapse

    Joined:
    Jan 30, 2021
    Messages:
    211
    i thought he was asking about the ui, but that makes more sense:p
     
  5. Meriel

    Meriel
    Expand Collapse

    Joined:
    Apr 9, 2021
    Messages:
    4
    Thanks, these both help. I'll inspect the lua for the pitch and roll UI apps and hopefully find documentation of pos,dir,up,front that's better than what BeamNG and beamNGpy provide :)
     
    • Like Like x 2
  6. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    This is some code that might help that I just took from my mod (you can find how to use vec3 in "BeamNG.drive\lua\common\mathlib.lua" and "LuaVec3" is equal to "vec3"):
    Code:
    --Vector that points where the car is facing
    local car_dir = vec3(obj:getDirectionVector())
    
    --Vector that points 90 degrees "up" from car_dir vector in a plane that runs in the direction of car and vertically 
    local car_dir_up = vec3(obj:getDirectionVectorUp())
    
    --Vector that is the cross product of car_dir and car_dir_up that points in lateral direction of the car
    local car_dir_right = vec3(obj:getDirectionVectorRight())
    
    --This one doesn't give you the center of the vehicle position
    local pos = vec3(obj:getPosition())
    
    --Offset by car_dir * 0.5 which seems to be a good aproximation of actual front position
    local front_pos = vec3(obj:getFrontPosition()) + car_dir * 0.5
    local center_pos = front_pos + -car_dir * obj:getInitialLength() * 0.5
    local rear_pos = front_pos + -car_dir * obj:getInitialLength()
    
    --usage example: print(car_dir.x)
    
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice