• What would be the best way to create a 'kick animation'
    8 replies, posted
Hi, I want to create a swep to kick doors open and i'm wondering what is the best way to create a new animation, for exemple in the m9k package you have weapon fist, is that a custom animation ? How did they manage to do such an anim ? I looked into the 'Player animation' wiki and its written : 'it is technically impossible at the moment to *add* onto the existing animations, sadly' What does it means ? I was thinking of make the player invisible and spawn in a ragdoll then maybe moove the ragdoll instead of creating an animation ? I'm clueless about what should i do... I'm willing to learn but i don't want to go on a dirty solution. If you can just tell me what kind of process i should follow or give me a link it would be appreciated... PS : I want to use HL2 player models, is that a problem ? Thanks in advance for any lead !
You can use JetBoom's animation API to create your own animations in Lua. Alternatively, you can use a BuildBonePositions callback (see Entity:AddCallback) to manually move the bones in the way you want.
Like code_gs suggested, Jet's AnimationsAPI is definitely the easiest way to go about it without having to make separate models. And his API uses ManipulateBonePosition internally.
I personally wouldn't recommend using it since it can conflict with other addons. Using a BuildBonePositions callback will maintain that support since bone manipulations are applied afterwards.
i'm a bit confused on where i should call the BuildBonePosition i only see 3 callback ! Should i add it in a "BuildBonePositions" hook? It seems to be triggered every damn frame !
Example on how to add a callback is on the page - just substitute the first argument with "BuildBonePositions". It's called every frame since player bone positions are updated that often, and the bone positions for the animations should be, as well.
I did add a callback, but I'm using it in a swep, only way to add it is in the 'initialize' function, but if SWEP:Initialize() fire multiple time it will add multiple callback no ? Should I check if the callback is instantied at each SWEP:Init ?
You can store the callbackid returned by AddCallback on the weapon, then before adding a new callback, check if there is a callbackid available. Ex. function SWEP:AddPlayerCallback() -- Callback doesn't exist yet if (self.m_iBoneCallback == nil) then local pOwner = self:GetOwner() if (pOwner:IsValid()) then self.m_iBoneCallback = pOwner:AddCallback("BuildBonePositions", funchere) end end end Whenever you remove the callback, set m_iBoneCallback to nil. Alternatively, it might be better to store the variable on the player entity instead of the weapon.
function SWEP:PrimaryAttack()   if not IsFirstTimePredicted() then return end   self:Initialize() end function SWEP:SecondaryAttack()   if not IsFirstTimePredicted() then return end   self:RemoveCallbackZ('bbpcbid') end function SWEP:RemoveCallbackZ( varIndex )   if self.Owner:GetTable()[varIndex] then     self.Owner:RemoveCallback("BuildBonePositions", self.Owner:GetTable()[varIndex])     self.Owner:SetVar(varIndex, nil )   end end function SWEP:DrawWorldModel() return false end function SWEP:Deploy() self.Owner:DrawViewModel(false) end function SWEP:Initialize()   self:SetHoldType(self.HoldType)     if not self.Owner:GetTable()['bbpcbid'] then       print("no bbpcbid in player table, adding one")       local callbackId = self.Owner:AddCallback("BuildBonePositions", function(entTarget)          local head = entTarget:LookupBone("ValveBiped.Bip01_Head1")          local headPos,headAng = entTarget:GetBonePosition(head)                  entTarget:SetBonePosition(head, headPos + Vector(0,0,10), headAng)       end )       self.Owner:SetVar("bbpcbid", callbackId )     end     --self.Owner:RemoveCallback( "BuildBonePositions", number callbackid ) end Ok so my callback is giving my player a 'long neck', when i right click it's supposed to remove the callback (it did remove it) but it's only working clientside, player still see me with a long neck even if i remove the callback and when i look in the camera it works fine for me... I did make the update to 'add' RemoveCallback serverside (i don't have any error anymore) so i don't understand wtf is happening
Sorry, you need to Log In to post a reply to this thread.