Recently I’ve been looking on the wiki for ways to implement animations such as idle and others into a SWEP, yet have had little success in doing so. One of the main issues is the right place to actually put in the sequence code into the rest of the file, another is what the code should actually be.
To whom it may concern, why won’t the code run the “ActionIdle” sequence for the Vortigaunt. The vortigaunt adopts the correct pose but has its head slightly crooked and seems stuck on the first frame of the animation.
shared.lua
SWEP.Author = "";
SWEP.Contact = "";
SWEP.Purpose = "";
SWEP.Instructions = "";
SWEP.Category = ""
SWEP.PrintName = "TestSWEP"
SWEP.Spawnable = true;
SWEP.AdminSpawnable = true;
SWEP.ViewModel = "models/weapons/v_pistol.mdl";
SWEP.WorldModel = "models/weapons/w_pistol.mdl";
SWEP.Primary.ClipSize = 100;
SWEP.Primary.DefaultClip = 100;
SWEP.Primary.Automatic = false;
SWEP.Primary.Ammo = "none";
function SWEP:Initialize()
--if( SERVER ) then
--self:SetWeaponHoldType( "normal" );
--end
end
function SWEP:Precache()
end
function SWEP:Deploy()
self.Owner:SetModel("models/vortigaunt.mdl")
end
function SWEP:PrimaryAttack()
local trace = self.Owner:GetEyeTrace();
util.ParticleTracerEx("vortigaunt_beam", trace.StartPos, trace.HitPos, true, 0, -1)
--local sequence = self.Owner:LookupSequence("zapattack1")
--self.Owner:SetSequence(sequence)
self.Weapon:SetNextPrimaryFire( CurTime() + 10.0 );
end
function SWEP:SecondaryAttack()
end
function SWEP:Reload()
end
--local NexThink = CurTime() + dur
function SWEP:Think()
local seq = self.Owner:LookupSequence("ActionIdle")
self.Owner:ResetSequence(seq)
local dur = self.Owner:SequenceDuration("ActionIdle")
self.Owner:NextThink(CurTime() + dur)
return true
--if( CurTime() >= NextThink ) then
--self.Owner:ResetSequence(seq)
--end
end
If cl_init and init are pertinent I will post them, but for the most part the code inside is simply auxiliary stuff. If you need me to clarify anything I’ll do so to the best of my ability.