garrysmod
garrysmod copied to clipboard
Tool ghost entity improvements
I have fixed the jittering ghost entities for tools when you move them about, this happens because it's being updated in a TOOL:Think function, which isn't called at the client's FPS. I have moved the update ghost entity function for each tool into a TOOL:DrawHUD function, which is called every frame. I have also made balloons align with the surface normal, which feels more natural.
Before: https://user-images.githubusercontent.com/53242610/121425487-5da8ec00-c96a-11eb-89f6-5ae62ad4ab38.mp4
After: https://user-images.githubusercontent.com/53242610/121425559-731e1600-c96a-11eb-84ee-0a4c8ea8d8a1.mp4
This breaks the ghost in single-player due to it existing as a serverside entity, not a clientside one.
This breaks the ghost in single-player due to it existing as a serverside entity, not a clientside one.
Ah you are right, is there any reason it's a serverside entity when in singleplayer?
It could have been a choice made before Garry added the hack to Think to be called shared in single-player, or maybe some CSEnt behaviour was broken in SP at one point. Either way it's too late to change now since some custom tools access the variable directly in a specific realm. Also, SWEP:DrawHUD is not going to be called if cl_drawhud is 0. You could instead use a Think hook which is called every frame on the client as opposed to being tied to server ticks.
Would putting the update ghost entity function inside of a Think hook be a viable option?
function TOOL:Deploy()
hook.Add( "Think", self, function()
self:UpdateGhostBalloon( self.GhostEntity, self:GetOwner() )
end)
end
I wouldn't use self as the key since that has a higher chance of conflicting, but that is a valid solution.
Closing due to lack of activity.