T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic interface Proximity<T extends com.badlogic.gdx.math.Vector<T>>
Proximity defines an area that is used by group behaviors to find and process the owner's neighbors.
Typically (but not necessarily) different group behaviors share the same Proximity for a given owner. This allows you to
combine group behaviors so as to get a more complex behavior also known as emergent behavior. Emergent behavior is behavior
that looks complex and/or purposeful to the observer but is actually derived spontaneously from fairly simple rules. The
lower-level agents following the rules have no idea of the bigger picture; they are only aware of themselves and maybe a few of
their neighbors. A typical example of emergence is flocking behavior which is a combination of three group behaviors:
separation, alignment, and cohesion. The three behaviors are typically
combined through a blended steering. This works okay but, because of the limited view distance of a
character, it's possible for an agent to become isolated from its flock. If this happens, it will just sit still and do
nothing. To prevent this from happening, you usually add in the wander behavior too. This way, all the agents
keep moving all the time. Tweaking the magnitudes of each of the contributing behaviors will give you different effects such as
shoals of fish, loose swirling flocks of birds, or bustling close-knit herds of sheep.
Before a steering acceleration can be calculated for a combination of group behaviors, the neighbors must be determined and
processed. This is done by the findNeighbors(com.badlogic.gdx.ai.steer.Proximity.ProximityCallback<T>) method and its callback argument.
Notes:
Proximity instance among group behaviors having the same owner can save a little time determining the
neighbors only once from inside the findNeighbors method. Especially, Proximity implementation classes can use
GdxAI.getTimepiece().getTime() to calculate neighbors only once per frame (assuming delta time is
always greater than 0, if time has changed the frame has changed too). This means that
update the timepiece on each frame the proximity instance will be
calculated only the very first time, which is not what you want of course.findNeighbors(ProximityCallback)
method.false from the method
reportNeighbor.| Modifier and Type | Interface and Description |
|---|---|
static interface |
Proximity.ProximityCallback<T extends com.badlogic.gdx.math.Vector<T>>
The callback object used by a proximity to report the owner's neighbor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
findNeighbors(Proximity.ProximityCallback<T> callback)
Finds the agents that are within the immediate area of the owner.
|
Steerable<T> |
getOwner()
Returns the owner of this proximity.
|
void |
setOwner(Steerable<T> owner)
Sets the owner of this proximity.
|
int findNeighbors(Proximity.ProximityCallback<T> callback)
reportNeighbor method of the specified callback.