I am new to BeamNG modding, and I'm trying to access some vehicle stats. Because I'm really not good with Lua I just want to write them to a socket and read that from another process. I found this relatively old thread about exporting vehicle data to a csv file, and it does still work. I am mainly interested in the vehicle's velocity, position and rotation. Said example however only accesses the position of the vehicle. By trial and error, I have also found obj:getVelocity() and obj:getRotation(). Velocity works fine, but rotation only seems to return the rotation speed, not the absolute rotation, which I would like to have. Also, it is just a scalar, so you can't just sum up the rotation over time because you don't know in which direction the rotation is being performed. So my question is, how would you access the vehicles rotation (as quaterion or euler angles)?
Here's how you can access the vehicle's rotation (quaternion): Code: local rot = quat(obj:getRotation()) local x, y, z, w = rot.x, rot.y, rot.z, rot.w
Alright here you go and also here's how you get the rotation in euler angles. Code: local rollAV, pitchAV, yawAV = obj:getRollPitchYawAngularVelocity() local rot = quat(obj:getRotation()):toEulerYXZ() local roll, pitch, yaw = rot.z, rot.y, rot.x
Sorry to reply to an old thread, but I am looking to get the current angular velocity of the vehicle in a camera script so I can apply some effects when the car is spinning quickly. obj:getRollPitchYawAngularVelocity() looks promising, but I don't see it used anywhere in the camera scripts. In driver.lua there is a commented out line: Code: local roll, pitch, yaw = data.veh:getRollPitchYawAngularVelocity() Uncommenting causes an error where getRollPitchYawAngularVelocity is nil. Is there a way to access the vehicle's angular velocity in a camera script?