So I’m making a SWEP that’s a melee weapon, but the view model doesn’t play the animation when i attack. Help please
Can someone please help me with this?
The wiki is always the first place you should look for an answer, if that doesn’t work try the search function. That solves most of my problems.
Yeah I looked on the wiki first, but I didn’t find anything.
EDIT: So if the animation I’m gonna use is “forwardattack” it should look like this?
function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end self.Weapon:EmitSound("bigswing.wav") self:ShootBullet( 150, 9, 0.75 ) self:TakePrimarymmo( 1 ) self.Owner:ViewPunch( Angle( -1, 0, 0 ) ) self.Weapon:SendWeaponAnim( ACT_VM_FORWARDATTACK ) end
It has to exist in ACT_ enumeration for it to work. For melee weapons I think what you need are the HIT and MISS ones such as ACT_VM_HITCENTER and ACT_VM_MISSCENTER.
Okay, the ACT_VM_HITCENTER didn’t work. Is there any way to find out what the enumeration is without having to change it and go back into gmod over and over? Like through SDK?
Can someone answer my question? Sorry for all the bumps.
function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end self.Weapon:EmitSound("bigswing.wav") self:ShootBullet( 150, 9, 0.75 ) self:TakePrimarymmo( 1 ) self.Owner:ViewPunch( Angle( -1, 0, 0 ) ) self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) end
What viewmodel are you using? Open it in Model Viewer (in Source SDK), and click the “sequences” tab (or whatever it is called, it’s the one that lets you select animations and play them). Then, in one of the menus (don’t remember which one), you should have an item called “Show activities”, if it’s not ticked, click it. Now, in the animations list, you should have a bunch of ACT_… enumerations instead of the sequence names. Find the one that you need, and you’re done.
Thanks, I wasn’t aware of that!