Open MagentaIris opened 10 years ago
Post code.
Mmhm, Sure thing, But i doubt that's gunna help you if you have a natural grasp of what i even meant.
You are not even returning the new values?
Yeah, I'm sure you take me for some kinda retard.
Returning the new values does nothing but destroy the cameras position and angles yet still force the view model to teleport/remove to Vector(0,0,0) then teleport/recreate back to my view.
Hosting a Listen Server has this problem. Starting a "Single Player Game" has the problem consist CONSTANTLY, Having the view model be at Vector(0,0,0) forever. Being on a Dedicated Server that i'm not hosting from my gmod client, Does NOT have this problem.
To add, On a dedicated server, The view model does the same behavior as a single player game if the game loads resources and hiccups for a small time (AKA, Load a high quality model and the game hiccups for 2 seconds, For those 2 seconds the view model is at Vector(0,0,0) and returning constantly)
To add, Once again, The same behavior seems to happen when even the slightest of hiccups happen, Setting the players velocity now causes the view model to crazily lag behind, when, In previous updates (The stable version 3 updates before this shit) It was perfectly damn fine.
The same problem also occurs while playing Elevator: Source in single player. I implemented the watch to use camera angles based off of an attachment. Anytime ViewModel.GetAttachment
is called within either the WEAP.CalcView
or WEAP.CalcViewModelView
hooks, the behavior shown in the video occurs.
Here's some code to reproduce the issue:
local attachName = 'muzzle'
hook.Add("CalcView", "GMod Issue #1255 - View Model Bug", function (ply)
local vm = ply:GetViewModel()
local attachId = vm:LookupAttachment(attachName)
-- Calling `vm.GetAttachment` causes the bug to occur
vm:GetAttachment(attachId)
end)
Save into garrysmod/lua
and open using lua_openscript_cl
. This should cause the issue on most HL2 weapons. You will notice the view model appears to lag a bit and will flicker. Make sure to test this in single player. However, it seems to also affect multiplayer a bit as well.
Hey nice job pinpointing the exact problem. This seems to come from SetupBones for some reason, I'll see what I can do about it. In the meantime, try calling vm:InvalidateBoneCache() at the end of your hook.
Calling vm:InvalidateBoneCache()
seems to fix the problem with the viewmodel jumping out of place, but it doesn't fix vm:GetAttachment(attachId)
returning bad angles every few frames. My guess is that the view model position/angles break before vm.GetAttachment
can grab the attachment info. Then calling vm.InvalidateBoneCache
fixes the position/angles after the fact.
Here's the updated code where you can see the view angles "flickering."
local attachName = 'muzzle'
local view = {}
hook.Add("CalcView", "GMod Issue #1255 - View Model Bug", function (ply, pos, angles, fov)
local vm = ply:GetViewModel()
local attachId = vm:LookupAttachment(attachName)
-- Calling `vm.GetAttachment` causes the bug to occur
local attach = vm:GetAttachment(attachId)
-- Calling `vm.InvalidateBoneCache` fixes the view model's position and
-- angles, but the attachment information may still be bad.
vm:InvalidateBoneCache()
view.origin = pos
view.fov = fov
-- The attach angles will be bad every few frames causing the screen to
-- 'flicker'
view.angles = attach.Ang
return view
end)
Again, make sure to test in single player.
For some reason this doesn't work diddly squat for me in Single Player, Or in Local MP, It might be because im setting positions and angles via xyz and pyr seperatly and not returning a view angle, Since iv'e never had to do that before as its always worked.
I'm setting the position and angle of the camera setups and its not working on my side, it seems to fail at the exact same rate as it used to without InvalidateBoneCache()
https://www.youtube.com/watch?v=rmrJr8CUh6Y
As seen here, Grabbing a view models attachment pos/ang and applying the players position/angle to it in CalcView, When an animation changes, Causes the view model, I think, To be removed and re-created.
I believe this is to do with the "Act commands no longer fuck networking animations properly", There is probly a mis-validation somewhere.