Jump to content

Snow Winter = Slide


Captain Cody

Recommended Posts

How would I globally decrease the grip of car tires to simulate traction loss in ice/snow?

Hi codylewiz,

Here's something I wrote just now. It does exactly what you want.

I've added in a function to reset every handling property globally so you can play around with different properties and settings.

This isn't necessary because if you remove one of the properties in the second function then those properties won't get reset to their default values.

Hope this helps,

Tails

  
function resetHandling() 
    for _,veh in pairs(getElementsByType("vehicle")) do 
        local model = getElementModel(veh) 
        local propTable = getOriginalHandling(model) 
        for k,v in pairs(propTable) do 
            setVehicleHandling(veh,k,v) 
        end 
    end 
end 
addEventHandler("onResourceStart",root,resetHandling) 
  
function changeHandling(veh) 
    local model = getElementModel(veh) 
    local propTable = getOriginalHandling(model) 
     
    local prop = "tractionLoss" 
    local value = propTable[prop] 
    setVehicleHandling(veh,prop,value-0.25) 
    outputChatBox("Original "..prop.." value: "..value,source) 
     
    local prop = "tractionBias" 
    local value = propTable[prop] 
    setVehicleHandling(veh,prop,value+0.20) 
    outputChatBox("Original "..prop.." value: "..value,source) 
end 
addEventHandler("onPlayerVehicleEnter",root,changeHandling) 
  

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