'Path Follow' is a behavior where an AICharacter moves from one path to the other without stopping at any path. It can be used for a patrolling type of behavior.
aiBehaviors.startFollow() // Required to start the follow
Position is a point in 3D space which falls on the path which the AI Character needs to traverse.
(Note: that you need to add multiple positions to create a path say for example Vec3(-10,10,0) Vec3(0,0,0) Vec3(10,10,0) Vec3(-10,10,0) will generate a rectangular path in the XY plane)
Note: the addToPath works backwards. So, your last call to addToPath will be your first position your AICharacter will go to.
The full working code in Pand3D is :
#for directx window and functions import direct.directbase.DirectStart #for most bus3d stuff from pandac.PandaModulesimport* #for directx object support from direct.showbase.DirectObjectimport DirectObject #for tasks from direct.taskimport Task #for Actors from direct.actor.Actorimport Actor #for Pandai from panda3d.aiimport*
#Path follow (note the order is reveresed) self.AIbehaviors.pathFollow() self.AIbehaviors.addToPath(self.target4.getPos()) self.AIbehaviors.addToPath(self.target3.getPos()) self.AIbehaviors.addToPath(self.target2.getPos()) self.AIbehaviors.addToPath(self.target1.getPos())
self.AIbehaviors.startFollow()
#AI World update taskMgr.add(self.AIUpdate,"AIUpdate")
#to update the AIWorld def AIUpdate(self,task): self.AIworld.update() return Task.cont