• SNPC Doesn't play gestures sometimes
    4 replies, posted
Having trouble with my SNPC, I am trying to make it play a gesture every 2 seconds but sometimes instead of playing the full animation it just jumps (As if it was a hiccup). Here's the code I'm using: function ENT:BodyUpdate() self:BodyMoveXY() end function ENT:Think() self:SetEyeTarget(self:GetPos()) if(CLIENT) then return end if(self:GetEnemy() && self:GetEnemy():IsValid()) then local dist = self:GetPos():Distance(self:GetEnemy():GetPos()) if(dist <= 100) then if(self.Attack == false) then self:SetPlaybackRate(1) self:RestartGesture(ACT_GMOD_GESTURE_RANGE_ZOMBIE) self.Attack = true timer.Simple(2, function() if(self && self:IsValid()) then self.Attack = false end end) end end end self:NextThink(CurTime()) end Here's what it looks like: https://streamable.com/44e1p
Mmmmm bump
It seems that the gesture is snapping back to it's original "starting point," if you will, and it's causing the hiccup effect. I believe I've found some idle animations here under Movement types. Try setting the idle animation, and then doing the zombie animation, after the first playback of the animation. What this means is that you should first set the zombie animation, after it's complete, set the idle for a split second, then set the zombie animation again. I hope that I was able to help you out.
Yup, that did fix it. I just had to start the walking activity before restarting the gesture and making sure I fully waited the animation to end (In this case around 2.2 seconds just to make sure all of the different animations fit)
Glad I was able to help!
Sorry, you need to Log In to post a reply to this thread.