I am using AIBehaviors to have my actor follow a path. What I can’t really find in the manual or API, is how to interrupt my actor during moving (i.e. to make him and the behavior stop or to reset the behavior alltogether, because its target has been destroyed). I initialize the char/behavior as follows:
# Create AI world, character and behaviors self.aiWorld = AIWorld(render) self.aiChar = AICharacter(model_name="GameActor", model_np=self.node, mass=20, movt_force=0.025, max_force=2.0) self.aiWorld.addAiChar(self.aiChar) self.aiBehaviors = self.aiChar.getAiBehaviors()
When I want my actor to go somewhere, I do:
and in a loop I add a bunch of points:
To start the moving:
I use a task to call
def updateMove(self, task): self.aiWorld.update() if self.behaviorDone() or not self.path: self.aiBehaviors.removeAi('pursue') self.moveArrived() return task.done return task.again
Where moveArrived() is my own method to handle anything to do after arriving at the destination.
Now, I’d like to be able to call a method (i.e. stopMove()) that interrupts the path following, so I may set a new destination/path alltogether. However, none of my attempts are succesful. self.aiBehaviors.removeAi(‘pursue’) doesn’t do the trick. I saw a method self.aiBehaviors.arrival() that supposedly should trigger arrival, but documentation on it is thin and it doesn’t seem to work either.