RANDOM USER PROJECTS

## Panda3D Manual: Wander

'Wander' is an AI behavior where an AICharacter will move in a random direction to generate realistic movement around an environment with no goal position in mind.

In PandAI, 'Wander' is defined as :

`aiBehaviors.wander(double wander_radius, int flag, double aoe, float priority)`

where :

Wander Radius represents the degree of wandering. This is implemented via a guiding circle in front of the AI Character.

Flag represents which plane to wander in (0 - XY, 1 - YZ, 2 - XZ, 3 - XYZ). By default, it is in the XY plane.

Area of Effect is the radius from the starting point where the AICharacter would wander within.

priority is by default set to 1.0 and is used when using two or more steering behaviors on an AICharacter.

The velocity at which the AICharacter wanders is determined when you first create your AICharacter object using the AICharacter constructor.

The full working code for this in Panda3D :

```import direct.directbase.DirectStart
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
from direct.actor.Actor import Actor
#for Pandai
from panda3d.ai import *

# Globals
speed = 0.75

class World(DirectObject):

def __init__(self):
base.disableMouse()
base.cam.setPosHpr(0,0,55,0,-90,0)

self.setAI()

# Seeker
ralphStartPos = Vec3(0, 0, 0)
self.wanderer = Actor("models/ralph",
{"run":"models/ralph-run"})
self.wanderer.reparentTo(render)
self.wanderer.setScale(0.5)
self.wanderer.setPos(ralphStartPos)

def setAI(self):
#Creating AI World
self.AIworld = AIWorld(render)

self.AIchar = AICharacter("wanderer",self.wanderer, 100, 0.05, 5)
self.AIbehaviors = self.AIchar.getAiBehaviors()

self.AIbehaviors.wander(5, 0, 10, 1.0)
self.wanderer.loop("run")

#AI World update