Hi, I've encountered a problem while trying to animate the viewmodel of fists. I was trying to do a simple right hand punch animation That's what happens:
https://files.facepunch.com/forum/upload/133929/ae856e25-ac68-4504-9cea-17d2daf90434/Half Life Source 01.23.2018 - 12.51.25.03.DVR_1.gif
And here's the code (it's in a SWEP file):
function SWEP:Think()
if CLIENT and used == true then
local vm = self.Owner:GetViewModel()
local id, dur = vm:LookupSequence("fists_right");
vm:ResetSequenceInfo();
vm:SendViewModelMatchingSequence( id )
vm:SetPlaybackRate(1);
vm:SetCycle(0);
timer.Simple(dur, function()
used = false
end)
end
end
I also tried running it only once, but it looked like only one frame was being rendered(I think the idle animation just stopped for one frame):
function SWEP:Think()
if CLIENT and used == true then
local vm = self.Owner:GetViewModel()
local id, dur = vm:LookupSequence("fists_right");
vm:ResetSequenceInfo();
vm:SendViewModelMatchingSequence( id )
vm:SetPlaybackRate(1);
vm:SetCycle(0);
used = false
end
end
The question is why does that happen and how to fix it?
Sidenote: It took me a really long time to even find something about hand animation, it's still confusing to me (I looked at wiki, forum, scripts of other people and slapped them together. Is there any tutorial about these animations?)
Check out the source code for the gmod default weapon_fists
garrysmod/weapon_fists.lua at master · Facepunch/garrysmod · Git..
Thanks but I checked this out earlier, I've got the punch to work but I'm trying to do something else (does this have something to do with the primary attack function?). For now I want to play a viewmodel animation by pressing E (and here animation isn't working properly)- I'm not focused on the punching part, this was just an example so I can later attach custom animations. Sorry for not clarifying it earlier
Sorry, you need to Log In to post a reply to this thread.