• Type Parameters:
T - Type of vector, either 2D or 3D, implementing the Vector interface
Direct Known Subclasses:
FollowPath, Hide, Interpose

extends SteeringBehavior<T>
Arrive behavior moves the agent towards a target position. It is similar to seek but it attempts to arrive at the target position with a zero velocity.

Arrive behavior uses two radii. The arrivalTolerance lets the owner get near enough to the target without letting small errors keep it in motion. The decelerationRadius, usually much larger than the previous one, specifies when the incoming character will begin to slow down. The algorithm calculates an ideal speed for the owner. At the slowing-down radius, this is equal to its maximum linear speed. At the target point, it is zero (we want to have zero speed when we arrive). In between, the desired speed is an interpolated intermediate value, controlled by the distance from the target.

The direction toward the target is calculated and combined with the desired speed to give a target velocity. The algorithm looks at the current velocity of the character and works out the acceleration needed to turn it into the target velocity. We can't immediately change velocity, however, so the acceleration is calculated based on reaching the target velocity in a fixed time scale known as timeToTarget. This is usually a small value; it defaults to 0.1 seconds which is a good starting point.

• ### Field Detail

• #### target

The target to arrive to.
• #### arrivalTolerance

protected float arrivalTolerance
The tolerance for arriving at the target. It lets the owner get near enough to the target without letting small errors keep it in motion.

The radius for beginning to slow down
• #### timeToTarget

protected float timeToTarget
The time over which to achieve target speed
• ### Constructor Detail

• #### Arrive

public Arrive(Steerable<T> owner)
Creates an Arrive behavior for the specified owner.
Parameters:
owner - the owner of this behavior
• #### Arrive

public Arrive(Steerable<T> owner,
Location<T> target)
Creates an Arrive behavior for the specified owner and target.
Parameters:
owner - the owner of this behavior
target - the target of this behavior
• ### Method Detail

• #### getTarget

public Location<T> getTarget()
Returns the target to arrive to.
• #### setTarget

public Arrive<T> setTarget(Location<T> target)
Sets the target to arrive to.
Returns:
this behavior for chaining.
• #### getArrivalTolerance

public float getArrivalTolerance()
Returns the tolerance for arriving at the target. It lets the owner get near enough to the target without letting small errors keep it in motion.
• #### setArrivalTolerance

public Arrive<T> setArrivalTolerance(float arrivalTolerance)
Sets the tolerance for arriving at the target. It lets the owner get near enough to the target without letting small errors keep it in motion.
Returns:
this behavior for chaining.

Returns the radius for beginning to slow down.

Sets the radius for beginning to slow down.
Returns:
this behavior for chaining.
• #### getTimeToTarget

public float getTimeToTarget()
Returns the time over which to achieve target speed.
• #### setTimeToTarget

public Arrive<T> setTimeToTarget(float timeToTarget)
Sets the time over which to achieve target speed.
Returns:
this behavior for chaining.
• #### setOwner

public Arrive<T> setOwner(Steerable<T> owner)
Description copied from class: SteeringBehavior
Sets the owner of this steering behavior.
Overrides:
setOwner in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>
Returns:
this behavior for chaining.
• #### setEnabled

public Arrive<T> setEnabled(boolean enabled)
Description copied from class: SteeringBehavior
Sets this steering behavior on/off.
Overrides:
setEnabled in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>
Returns:
this behavior for chaining.
• #### setLimiter

public Arrive<T> setLimiter(Limiter limiter)
Sets the limiter of this steering behavior. The given limiter must at least take care of the maximum linear speed and acceleration.
Overrides:
setLimiter in class SteeringBehavior<T extends com.badlogic.gdx.math.Vector<T>>
Returns:
this behavior for chaining.