mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
init
This commit is contained in:
19
lua/entities/gmod_train_wheels/cl_init.lua
Normal file
19
lua/entities/gmod_train_wheels/cl_init.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
Reference in New Issue
Block a user