Captain Cody Posted December 8, 2015 Share Posted December 8, 2015 How would I globally decrease the grip of car tires to simulate traction loss in ice/snow? Link to comment
Captain Cody Posted December 8, 2015 Author Share Posted December 8, 2015 Any way to do this globally instead of manually going through and setting the handlings. Link to comment
Dealman Posted December 8, 2015 Share Posted December 8, 2015 Yeah, you can. Use getElementsByType to get all the vehicles, then loop through them and use setVehicleHandling. Link to comment
Tails Posted December 9, 2015 Share Posted December 9, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now