• Playing animations on weapon worldmodel
    4 replies, posted
Hello, I'm working on a SWEP and I would like thirdperson to play a massive role. My question is if it would be possible to run functions such as ResetSequence on the worldmodel in order to animate it. I haven't had any luck with my tests, possibly because the worldmodel's animation is updated to the idle animation every frame? If ResetSequence is not an option, then I would be perfectly happy to render a ClientSideModel and animate it with the help of ResetSequence and SetCycle. My only question is how does Garry's Mod attach the worldmodel to the player's hands (because self:GetPos() returns the player's crotch)? Bonemerging? Attachments? If so, I've never really worked with either so any code snippets to nudge me in the right direction would be amazing as I can't find much information regarding worldmodels anywhere. Viewmodels are so incredibly flexible in this game but Worldmodels seem to be a pain in the ass to do anything remotely interesting with. Thank you!
Turns out that was a tad easier than I was expecting (looking at your bonemerger code), but it seems I am still unable to set the sequence like this: function SWEP:DrawWorldModel()     local mdl = ClientsideModel( self.WorldModel, RENDERGROUP_OTHER )     mdl:SetParent( self, 0 ) mdl:AddEffects( EF_BONEMERGE )     mdl:ResetSequence( mdl:LookupSequence( "rotate" ) )     mdl:SetCycle( 0.5 )     mdl:DrawModel()     mdl:Remove() end The Wiki says that it requires that ResetSequence be done in the tick after setting the model, but this doesn't work either: if CLIENT then     local mdl = ClientsideModel( SWEP.WorldModel, RENDERGROUP_OTHER )     function SWEP:DrawWorldModel()         mdl:SetParent( self, 0 )         mdl:AddEffects( EF_BONEMERGE )         mdl:ResetSequence( mdl:LookupSequence( "rotate" ) )         mdl:SetCycle( 0.5 )         mdl:DrawModel()     end end Which is confusing because I swear I've managed to get ResetSequence behaving properly with ClientsideModel
Oh boy, you don't want to be constantly recreating and removing the ClientsideModel. You should create it in something like SWEP:Initialize and then just use DrawModel and other logic in SWEP:DrawWorldModel()
I've tried that but without any luck. I'm still unable to play sequences on the model.
Sorry, you need to Log In to post a reply to this thread.