Facepunch / garrysmod-issues

Garry's Mod issue tracker
139 stars 56 forks source link

Rotating doors are slower on high tickrate servers #5262

Open mgetJane opened 2 years ago

mgetJane commented 2 years ago

demonstration video: https://youtu.be/l1E5MplUOnI

map used in the video: tickrot.vmf

afaik this is currently an issue with every source engine game including tf2, css, csgo, etc

linear-moving entities (func_door, func_movelinear, etc) are unaffected

this basically means that on 100 tick servers, rotating doors/levers/etc take 50% longer to open and close, while on 128 tick servers, they take 92% longer (almost twice as slow than they should be)

low tickrate servers seem to be unaffected, rotating entities take about as long as they should on 66.67 tick

this script shows that when angular velocity is multiplied by the product of the server's tickrate and 0.015, rotating doors/etc take the correct amount of time to open and close

local tickrate = math.floor(1 / engine.TickInterval())

if tickrate < 67 then
    return
end

local mult = tickrate * 0.015

for _, v in pairs(ents.FindByClass"prop_door_rotating") do
    v:SetSaveValue("m_flSpeed", v:GetInternalVariable"m_flSpeed" * mult)
end

for _, v in pairs(ents.FindByClass"func_door_rotating") do
    v:SetSaveValue("m_flSpeed", v:GetInternalVariable"m_flSpeed" * mult)
end

for _, v in pairs(ents.FindByClass"func_rotating") do
    v:SetSaveValue("m_flMaxSpeed", v:GetInternalVariable"m_flMaxSpeed" * mult)
end

for _, v in pairs(ents.FindByClass"func_rot_button") do
    v:SetSaveValue("m_flSpeed", v:GetInternalVariable"m_flSpeed" * mult)
end

for _, v in pairs(ents.FindByClass"momentary_rot_button") do
    v:SetSaveValue("m_flSpeed", v:GetInternalVariable"m_flSpeed" * mult)
    v:SetSaveValue("m_returnSpeed", v:GetInternalVariable"m_returnSpeed" * mult)
end
mgetJane commented 6 months ago

(note that this is only an issue with SOLID_VPHYSICS, the speeds work fine with brushes set to SOLID_BSP)