meta data for this page
Vehicles/VehicleScripts/CylinderAnimator.lua
CylinderAnimator initializes cylinders from lua. You can also achieve the same effect by adding the LuaCylinder
component to the object via Modding SDK.
The script needs three indexes:
cylinderIndex
specifies the cylinder. It will always be rotated in such way that its Z axis hits the target.pistonIndex
represents the piston. This should be a child object of the cylinder. Its pivot will be placed exactly to the target.targetIndex
specifies the target.
In many use cases, the cylinder will be the child of some stationary part (e.g. the body of a snowcat). On the other hand, the target will be child of some moving part (e.g. the snowcat's groomer or blade). CylinderAnimator ensures that the cylinder will always be connected to the target.
For performance reasons, the actual runtime calculations are done via C#. If necessary, you can view the source code in the Modding SDK.
35 CylinderAnimator = CylinderAnimator or {};
CylinderAnimator:load(dataTable)
This sets up the LuaCylinder component for each cylinder in the data table.
39 function CylinderAnimator:load(dataTable) 40 self.cylinders = {}; 41 42 if dataTable.cylinders ~= nil then 43 for k, v in pairs(dataTable.cylinders) do 44 local id = getChild(self.id, v.cylinder or v.cylinderIndex or ""); 45 46 if id ~= nil then 47 local cylinder = {}; 48 cylinder.cylinderId = id; 49 cylinder.pistonId = getChild(self.id, v.piston or v.pistonIndex or ""); 50 cylinder.targetId = getChild(self.id, v.target or v.targetIndex or ""); 51 52 table.insert(self.cylinders, cylinder); 53 54 -- update by C# 55 Cylinder.new(cylinder.cylinderId, cylinder.pistonId, cylinder.targetId); 56 end; 57 end; 58 end; 59 end;
Copyright
All contents of this page may be used for modding use for Winter Resort Simulator only. Any use exceeding this regulation is not permitted.
Copyright (C) HR Innoways, 2020. All Rights Reserved.