1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
Files
MetrostroiAddon/lua/entities/gmod_train_wheels/cl_init.lua
g_brzhezinskiy 1d05caf866 init
2021-01-02 12:51:45 +03:00

20 lines
559 B
Lua

include("shared.lua")
function ENT:Think()
if self:GetNW2Bool("Disabled") then return end
-- Timing
self.PrevTime = self.PrevTime or RealTime()
local dT = (RealTime() - self.PrevTime)
self.PrevTime = RealTime()
-- Angular velocity
local wheel_radius = 0.5*44.1 -- units
local speed = -self:GetVelocity():Dot(self:GetAngles():Right())
local ang_vel = speed/(2*math.pi*wheel_radius)
-- Rotate wheel
self.Angle = ((self.Angle or math.random()) + ang_vel*dT) % 1.0
self:SetPoseParameter("position",1.0-self.Angle)
--self:InvalidateBoneCache()
end