• animation not playing all the way through - swep
    2 replies, posted
hello i have a script that plays an animation on primary fire but it dosn't go all the way through the animation but sometimes it dose [CODE]function SWEP:PrimaryAttack() if !IsFirstTimePredicted() then return end local trace = self.Owner:GetEyeTrace() if CLIENT then surface.PlaySound("tools/hammer_hit2.wav") end self:SendWeaponAnim(ACT_VM_HITCENTER) local effectdata = EffectData() effectdata:SetEntity(trace.Entity) effectdata:SetOrigin( trace.HitPos ) effectdata:SetNormal( trace.HitNormal ) effectdata:SetMagnitude( 1 ) effectdata:SetScale( 1 ) effectdata:SetRadius( 1 ) util.Effect( "Sparks", effectdata ) self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end[/CODE] [URL="https://youtu.be/x6paKw6QDhE"]here[/URL] is a vid of the results ACT_VM_HITCENTER is the swing animation help will be thanked
Only use IsFirstTimePredicted for unpredicted functions. [code]function SWEP:PrimaryAttack() if IsFirstTimePredicted() then local trace = self:GetOwner():GetEyeTrace() local effectdata = EffectData() effectdata:SetEntity( trace.Entity ) effectdata:SetOrigin( trace.HitPos ) effectdata:SetNormal( trace.HitNormal ) effectdata:SetMagnitude( 1 ) effectdata:SetScale( 1 ) effectdata:SetRadius( 1 ) util.Effect( "Sparks", effectdata ) if CLIENT then surface.PlaySound( "tools/hammer_hit2.wav" ) end end local delay = CurTime() + self.Primary.Delay self:SetNextPrimaryFire( delay ) self:SetNextSecondaryFire( delay ) self:SendWeaponAnim( ACT_VM_HITCENTER ) end[/code]
[QUOTE=code_gs;50672699]Only use IsFirstTimePredicted for unpredicted functions. [code]function SWEP:PrimaryAttack() if IsFirstTimePredicted() then local trace = self:GetOwner():GetEyeTrace() local effectdata = EffectData() effectdata:SetEntity( trace.Entity ) effectdata:SetOrigin( trace.HitPos ) effectdata:SetNormal( trace.HitNormal ) effectdata:SetMagnitude( 1 ) effectdata:SetScale( 1 ) effectdata:SetRadius( 1 ) util.Effect( "Sparks", effectdata ) if CLIENT then surface.PlaySound( "tools/hammer_hit2.wav" ) end end local delay = CurTime() + self.Primary.Delay self:SetNextPrimaryFire( delay ) self:SetNextSecondaryFire( delay ) self:SendWeaponAnim( ACT_VM_HITCENTER ) end[/code][/QUOTE] woop woop thanks alot!
Sorry, you need to Log In to post a reply to this thread.