NextBot animations?

I have been trying pretty much every animation with every playermodel and normal hl2 model and none of the walking/running animations even move the legs. The animations work perfectly when I am using the playermodel myself.

Any ideas?



function ENT:RunBehaviour()
	while ( true ) do

		if ( self:HaveEnemy() ) then

			self.loco:FaceTowards( self:GetEnemy():GetPos() )

			self:StartActivity( ACT_RUN )
			self.loco:SetDesiredSpeed( 450 )
			self.loco:SetAcceleration( 900 )
			self:ChaseEnemy() 
			self.loco:SetAcceleration( 400 )			
			self:StartActivity( ACT_IDLE )

		else

			self:StartActivity( ACT_WALK )
			self.loco:SetDesiredSpeed( 200 )
			self:MoveToPos( self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 400 ) -- Walk to a random place within about 400 units ( yielding )
			self:StartActivity( ACT_IDLE )
		end
		coroutine.wait( 2 )
	end
end


You have to add self:SetPoseParameter() after every self:StartActivity() in order to make the bot move his legs.


	self.loco:FaceTowards( self:GetEnemy():GetPos() )

			self:StartActivity( ACT_HL2MP_RUN ) --You got to use HL2MP ACT Enumerations
			self:SetPoseParameter("move_x", 1 ) -- The "move_x" makes them move back and fordward, alternatively "move_y" makes them move side to side. The number sets the speed of the animation. It can be from 0 to 1 I belive, so it can only go slower...
			self.loco:SetDesiredSpeed( 450 )
			self.loco:SetAcceleration( 900 )

Here is the long list of ACT Enumerations, the ones that work for player model based nextbots are the HL2MP ones wich are almost at the very bottom.

https://wiki.garrysmod.com/page/Enums/ACT

Or you could do it like how I have done it:



function ENT:RunBehaviour()
	while true do
		self:StartActivity(ACT_WALK)
		self.loco:SetDesiredSpeed(100)
		self:MoveToPos(self:GetPos() + Vector(math.Rand(-1, 1), math.Rand(-1, 1), 0) * 400)
		self:StartActivity(ACT_IDLE)
		coroutine.wait(2)

		coroutine.yield()
	end
end


This makes the nextbot wait 2 seconds before doing his activity again. And when the nextbot does his activity, then the nextbot will move to a random place at a set distance (400 units).