VE Lua Documentation

Press F to search!

bodyCollision

Definition


-- @/lua/vehicle/sounds.lua:1016

local function bodyCollision(p)
  -- print((p.slipVel * p.normalForce * 0.001)..','..(p.slipVel * 0.01)..','..(p.normalForce * 0.01))
  local slipVel = p.slipVel
  if slipVel < 0.01 then
    return
  end
  local matid1, matid2 = p.materialID1, p.materialID2
  local event = scrapeMap[max(matid1, matid2)] or scrapeMap[min(matid1, matid2)]
  if not event then
    return
  end
  if scrapeAbsorbing[matid2] or scrapeAbsorbing[matid1] then
    if scrapeAbsorbing[matid2] == "wheel" or scrapeAbsorbing[matid1] == "wheel" then
      if v.data.nodes[p.id1].wheelID then
        return
      end
    else
      return
    end
  end
  local normalForce = p.normalForce
  obj:setNodeVolumePitchCT(event, p.id1, slipVel * normalForce / (normalForce + 6) * 8000, slipVel * 0.01, normalForce, max(M.scrapeLoosenessMap[matid1] or 0, M.scrapeLoosenessMap[matid2] or 0))
end

Callers

@/lua/vehicle/wheels.lua
      if p.slipForce > 0 and p.materialID ~= 4 and p.materialID2 ~= 4 then
        sounds.bodyCollision(p)
      end
    elseif p.slipForce > 0 then
      sounds.bodyCollision(p)
    end