T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class Alignment<T extends com.badlogic.gdx.math.Vector<T>> extends GroupBehavior<T> implements Proximity.ProximityCallback<T>
Alignment is a group behavior producing a linear acceleration that attempts to keep the owner aligned with the agents in
its immediate area defined by the given Proximity. The acceleration is calculated by first iterating through all the
neighbors and averaging their linear velocity vectors. This value is the desired direction, so we just subtract the owner's
linear velocity to get the steering output.
Cars moving along roads demonstrate Alignment type behavior. They also demonstrate Separation as they try to
keep a minimum distance from each other.
proximityenabled, limiter, owner| Constructor and Description |
|---|
Alignment(Steerable<T> owner,
Proximity<T> proximity)
Creates an
Alignment behavior for the specified owner and proximity. |
| Modifier and Type | Method and Description |
|---|---|
protected SteeringAcceleration<T> |
calculateRealSteering(SteeringAcceleration<T> steering)
Calculates the steering acceleration produced by this behavior and writes it to the given steering output.
|
boolean |
reportNeighbor(Steerable<T> neighbor)
The callback method used to report a neighbor.
|
Alignment<T> |
setEnabled(boolean enabled)
Sets this steering behavior on/off.
|
Alignment<T> |
setLimiter(Limiter limiter)
Sets the limiter of this steering behavior.
|
Alignment<T> |
setOwner(Steerable<T> owner)
Sets the owner of this steering behavior.
|
getProximity, setProximitycalculateSteering, getActualLimiter, getLimiter, getOwner, isEnabled, newVectorprotected SteeringAcceleration<T> calculateRealSteering(SteeringAcceleration<T> steering)
SteeringBehavior
This method is called by SteeringBehavior.calculateSteering(SteeringAcceleration) when this steering behavior is enabled.
calculateRealSteering in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>steering - the steering acceleration to be calculated.public boolean reportNeighbor(Steerable<T> neighbor)
Proximity.ProximityCallbackreportNeighbor in interface Proximity.ProximityCallback<T extends com.badlogic.gdx.math.Vector<T>>neighbor - the reported neighbor.true if the given neighbor is valid; false otherwise.public Alignment<T> setOwner(Steerable<T> owner)
SteeringBehaviorsetOwner in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>public Alignment<T> setEnabled(boolean enabled)
SteeringBehaviorsetEnabled in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>public Alignment<T> setLimiter(Limiter limiter)
setLimiter in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>