local pedalAnimFile = "../animations/pedal.ksanim"
local progress = 0
local pedal = ac.findNodes('pedal')
local pedalR = ac.findNodes('pedalR')
local pedalL = ac.findNodes('pedalL')

local driverLegAnimFile = "../animations/driver_pedal.ksanim"
local driverArmAnimFile = "../animations/steerAnim.ksanim"
local driver = ac.findNodes('DRIVER:DRIVER')

function script.update(dt)
    if ac.getCar().gas > 0 then
        progress = (progress + dt * 3 * (ac.getCar().rpm-800)/7000) % 1
    else
        progress = 0
    end
    pedal:setAnimation(pedalAnimFile,progress,false)
    pedalL:setAnimation(pedalAnimFile,progress,false)
    pedalR:setAnimation(pedalAnimFile,progress,false)
    driver:setAnimation(driverArmAnimFile,-ac.getCar().steer/math.abs(ac.getCar().steer) * (ac.getCar().steer/450)^2+0.5,false)
    driver:setAnimation(driverLegAnimFile,progress,false)

    print(ac.getCar().distanceToCamera)
end