meta data for this page
Vehicles/VehicleScripts/WheelSuspensionAnchor.lua
This script moves an anchor point that translates relative to the ingame wheel. Can be helpful while setting up complex suspension systems or just for moving something relative to a wheel but keeping steering ability.
25 WheelSuspensionAnchor = WheelSuspensionAnchor or {};
WheelSuspensionAnchor:load(dataTable)
Get the wheel and its anchor from the data table.
29 function WheelSuspensionAnchor:load(dataTable) 30 self.wheelSuspensions = {}; 31 32 if dataTable.wheelSuspension ~= nil then 33 for k, v in pairs(dataTable.wheelSuspension) do 34 if v.wheel ~= nil and v.wheel ~= "" then 35 local suspension = {}; 36 suspension.wheel = getChild(self.id, v.wheel); 37 suspension.wheelAnchor = getChild(self.id, v.wheelAnchor); 38 39 -- get difference between wheel and anchor location 40 local wheelPosition = VectorUtils.getPosition(suspension.wheel); 41 local anchorPosition = VectorUtils.getPosition(suspension.wheelAnchor); 42 suspension.distance = anchorPosition - wheelPosition; 43 44 table.insert(self.wheelSuspensions, suspension); 45 end; 46 end; 47 end; 48 end; 49
WheelSuspensionAnchor:update(dt)
Adjust the anchor's position.
53 function WheelSuspensionAnchor:update(dt) 54 for k,suspension in pairs(self.wheelSuspensions) do 55 local wheelPosition = VectorUtils.getPosition(suspension.wheel); 56 local anchorPosition = suspension.distance + wheelPosition; 57 VectorUtils.setPosition(suspension.wheelAnchor, anchorPosition); 58 end; 59 end;
Copyright
All contents of this page may be used for modding use for Winter Resort Simulator - Season 2 only. Any use exceeding this regulation is not permitted.
Copyright (C) HR Innoways, 2021. All Rights Reserved.