T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class FollowFlowField<T extends com.badlogic.gdx.math.Vector<T>> extends SteeringBehavior<T>
FollowFlowField behavior produces a linear acceleration that tries to align the motion of the owner with the local
tangent of a flow field. The flow field defines a mapping from a location in space to a flow vector. Any flow field can be used
as the basis of this steering behavior, although it is sensitive to discontinuities in the field.
For instance, flow fields can be used for simulating various effects, such as magnetic fields, an irregular gust of wind or the meandering path of a river. They can be generated by a simple random algorithm, a Perlin noise or a complicated image processing. And of course flow fields can be dynamic. The only limit is your imagination.
Like FollowPath, this behavior can work in a predictive manner when its predictionTime is greater than 0.
| Modifier and Type | Class and Description |
|---|---|
static interface |
FollowFlowField.FlowField<T extends com.badlogic.gdx.math.Vector<T>>
A
FlowField defines a mapping from a location in space to a flow vector. |
| Modifier and Type | Field and Description |
|---|---|
protected FollowFlowField.FlowField<T> |
flowField
The flow field to follow.
|
protected float |
predictionTime
The time in the future to predict the owner's position.
|
enabled, limiter, owner| Constructor and Description |
|---|
FollowFlowField(Steerable<T> owner)
Creates a non-predictive
FollowFlowField for the specified owner. |
FollowFlowField(Steerable<T> owner,
FollowFlowField.FlowField<T> flowField)
Creates a non-predictive
FollowFlowField for the specified owner and flow field. |
FollowFlowField(Steerable<T> owner,
FollowFlowField.FlowField<T> flowField,
float predictionTime)
Creates a
FollowFlowField with the specified owner, flow field and prediction time. |
| 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.
|
FollowFlowField.FlowField<T> |
getFlowField()
Returns the flow field of this behavior
|
float |
getPredictionTime()
Returns the prediction time.
|
FollowFlowField<T> |
setEnabled(boolean enabled)
Sets this steering behavior on/off.
|
FollowFlowField<T> |
setFlowField(FollowFlowField.FlowField<T> flowField)
Sets the flow field of this behavior
|
FollowFlowField<T> |
setLimiter(Limiter limiter)
Sets the limiter of this steering behavior.
|
FollowFlowField<T> |
setOwner(Steerable<T> owner)
Sets the owner of this steering behavior.
|
FollowFlowField<T> |
setPredictionTime(float predictionTime)
Sets the prediction time.
|
calculateSteering, getActualLimiter, getLimiter, getOwner, isEnabled, newVectorprotected FollowFlowField.FlowField<T extends com.badlogic.gdx.math.Vector<T>> flowField
protected float predictionTime
public FollowFlowField(Steerable<T> owner)
FollowFlowField for the specified owner.owner - the owner of this behaviorpublic FollowFlowField(Steerable<T> owner, FollowFlowField.FlowField<T> flowField)
FollowFlowField for the specified owner and flow field. Prediction time defaults to 0.owner - the owner of this behaviorflowField - the flow field to followpublic FollowFlowField(Steerable<T> owner, FollowFlowField.FlowField<T> flowField, float predictionTime)
FollowFlowField with the specified owner, flow field and prediction time.owner - the owner of this behaviorflowField - the flow field to followpredictionTime - the time in the future to predict the owner's position. Can be 0 for non-predictive flow field
following.protected 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 FollowFlowField.FlowField<T> getFlowField()
public FollowFlowField<T> setFlowField(FollowFlowField.FlowField<T> flowField)
flowField - the flow field to setpublic float getPredictionTime()
public FollowFlowField<T> setPredictionTime(float predictionTime)
predictionTime - the predictionTime to setpublic FollowFlowField<T> setOwner(Steerable<T> owner)
SteeringBehaviorsetOwner in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>public FollowFlowField<T> setEnabled(boolean enabled)
SteeringBehaviorsetEnabled in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>public FollowFlowField<T> setLimiter(Limiter limiter)
setLimiter in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>