Nextbot animations

When I call function with animation, in ENT:Think(), nextbot play this animation, but animation looks strange:

http://webmshare.com/play/DABMz

How to fix this glitch?

You are resetting the animation to its first frame every frame, naturally it will not play and be stuck on the first frame you are resetting it to.

Thanks for explanation. So, I need better place to run function with animation?

You need it to run once, wait for it to finish, run it again, etc.

Player animations works only with this method?

Any animation.

Ok, but how I can do this?

Do what? Play an animation once? Uh, don’t restart it every tick/frame.

No. Force animation to restart after playing. Timer or coroutine, or may something else?

Timer library, CurTime() timers, it’s up to you what you want to use.

All right. I went another way to fix this:



function ENT:Think

	local act = self:TranslateActivity(self:CalcMainActivity( self.loco:GetVelocity()) )      -- Getting our activity depending from our current conditions in world
	local seq = self:SelectWeightedSequence( act )                                                 -- Translate this activity to sequence
	
	self:BodyMoveXY()

	self:SetSequence(seq)
	
    if self:GetCycle(1) then self:ResetSequence( self:GetSequence() ) end	                 -- If cycle of sequence is ended, we restart it again, again and again...
	
end