T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class Jump<T extends com.badlogic.gdx.math.Vector<T>> extends MatchVelocity<T>
Jump behavior calculates the linear velocity required to achieve the jump. If the calculated velocity doesn't
exceed the maximum linear velocity the jump is achievable; otherwise it's not. In either cases, the given callback gets
informed through the reportAchievability method. Also, if the jump is
achievable the run up phase begins and the Jump behavior will start to produce the linear acceleration required to match
the calculated velocity. Once the jump point and the linear velocity are reached with a precision within the given tolerance
the callback is told to jump through the takeoff method.| Modifier and Type | Class and Description |
|---|---|
static interface |
Jump.GravityComponentHandler<T extends com.badlogic.gdx.math.Vector<T>>
A
GravityComponentHandler is aware of the axis along which the gravity acts. |
static interface |
Jump.JumpCallback
The
JumpCallback allows you to know whether a jump is achievable and when to jump. |
static class |
Jump.JumpDescriptor<T extends com.badlogic.gdx.math.Vector<T>>
A
JumpDescriptor contains jump information like the take-off and the landing position. |
| Modifier and Type | Field and Description |
|---|---|
protected float |
airborneTime |
protected Jump.JumpCallback |
callback |
static boolean |
DEBUG_ENABLED |
protected T |
gravity
The gravity vector to use.
|
protected Jump.GravityComponentHandler<T> |
gravityComponentHandler |
protected Jump.JumpDescriptor<T> |
jumpDescriptor
The jump descriptor to use
|
protected float |
maxVerticalVelocity
The maximum vertical component of jump velocity, where "vertical" stands for the axis where gravity operates.
|
protected float |
takeoffPositionTolerance |
protected float |
takeoffVelocityTolerance |
target, timeToTargetenabled, limiter, owner| Constructor and Description |
|---|
Jump(Steerable<T> owner,
Jump.JumpDescriptor<T> jumpDescriptor,
T gravity,
Jump.GravityComponentHandler<T> gravityComponentHandler,
Jump.JumpCallback callback)
Creates a
Jump behavior. |
| Modifier and Type | Method and Description |
|---|---|
float |
calculateAirborneTimeAndVelocity(T outVelocity,
Jump.JumpDescriptor<T> jumpDescriptor,
float maxLinearSpeed)
Returns the airborne time and sets the
outVelocity vector to the airborne planar velocity required to achieve the
jump. |
SteeringAcceleration<T> |
calculateRealSteering(SteeringAcceleration<T> steering)
Calculates the steering acceleration produced by this behavior and writes it to the given steering output.
|
T |
getGravity()
Returns the gravity vector.
|
Jump.JumpDescriptor<T> |
getJumpDescriptor()
Returns the jump descriptor.
|
float |
getMaxVerticalVelocity()
Returns the maximum vertical component of jump velocity, where "vertical" stands for the axis where gravity operates.
|
float |
getTakeoffPositionTolerance()
Returns the tolerance used to check if the owner has reached the takeoff location.
|
float |
getTakeoffVelocityTolerance()
Returns the tolerance used to check if the owner has reached the takeoff velocity.
|
Jump<T> |
setEnabled(boolean enabled)
Sets this steering behavior on/off.
|
Jump<T> |
setGravity(T gravity)
Sets the gravity vector.
|
Jump<T> |
setJumpDescriptor(Jump.JumpDescriptor<T> jumpDescriptor)
Sets the jump descriptor to use.
|
Jump<T> |
setLimiter(Limiter limiter)
Sets the limiter of this steering behavior.
|
Jump<T> |
setMaxVerticalVelocity(float maxVerticalVelocity)
Sets the maximum vertical component of jump velocity, where "vertical" stands for the axis where gravity operates.
|
Jump<T> |
setOwner(Steerable<T> owner)
Sets the owner of this steering behavior.
|
Jump<T> |
setTakeoffPositionTolerance(float takeoffPositionTolerance)
Sets the tolerance used to check if the owner has reached the takeoff location.
|
Jump<T> |
setTakeoffTolerance(float takeoffTolerance)
Sets the the tolerance used to check if the owner has reached the takeoff location with the required velocity.
|
Jump<T> |
setTakeoffVelocityTolerance(float takeoffVelocityTolerance)
Sets the tolerance used to check if the owner has reached the takeoff velocity.
|
Jump<T> |
setTarget(Steerable<T> target)
Sets the target whose velocity should be matched.
|
Jump<T> |
setTimeToTarget(float timeToTarget)
Sets the time over which to achieve target speed.
|
getTarget, getTimeToTargetcalculateSteering, getActualLimiter, getLimiter, getOwner, isEnabled, newVectorpublic static boolean DEBUG_ENABLED
protected Jump.JumpDescriptor<T extends com.badlogic.gdx.math.Vector<T>> jumpDescriptor
protected T extends com.badlogic.gdx.math.Vector<T> gravity
Jump.GravityComponentHandler.getComponent(Vector) method.protected Jump.GravityComponentHandler<T extends com.badlogic.gdx.math.Vector<T>> gravityComponentHandler
protected Jump.JumpCallback callback
protected float takeoffPositionTolerance
protected float takeoffVelocityTolerance
protected float maxVerticalVelocity
protected float airborneTime
public Jump(Steerable<T> owner, Jump.JumpDescriptor<T> jumpDescriptor, T gravity, Jump.GravityComponentHandler<T> gravityComponentHandler, Jump.JumpCallback callback)
Jump behavior.owner - the owner of this behaviorjumpDescriptor - the descriptor of the jump to makegravity - the gravity vectorgravityComponentHandler - the handler giving access to the vertical axiscallback - the callback that gets informed about jump achievability and when to jumppublic SteeringAcceleration<T> calculateRealSteering(SteeringAcceleration<T> steering)
SteeringBehavior
This method is called by SteeringBehavior.calculateSteering(SteeringAcceleration) when this steering behavior is enabled.
calculateRealSteering in class MatchVelocity<T extends com.badlogic.gdx.math.Vector<T>>steering - the steering acceleration to be calculated.public float calculateAirborneTimeAndVelocity(T outVelocity, Jump.JumpDescriptor<T> jumpDescriptor, float maxLinearSpeed)
outVelocity vector to the airborne planar velocity required to achieve the
jump. If the jump is not achievable -1 is returned and the outVelocity vector remains unchanged.
Be aware that you should avoid using unlimited or very high max velocity, because this might produce a time of flight close to 0. Actually, the motion equation for T has 2 solutions and Jump always try to use the fastest time.
outVelocity - the output vector where the airborne planar velocity is calculatedjumpDescriptor - the jump descriptormaxLinearSpeed - the maximum linear speed that can be used to achieve the jumppublic Jump.JumpDescriptor<T> getJumpDescriptor()
public Jump<T> setJumpDescriptor(Jump.JumpDescriptor<T> jumpDescriptor)
jumpDescriptor - the jump descriptor to setpublic T getGravity()
public Jump<T> setGravity(T gravity)
gravity - the gravity to setpublic float getMaxVerticalVelocity()
public Jump<T> setMaxVerticalVelocity(float maxVerticalVelocity)
maxVerticalVelocity - the maximum vertical velocity to setpublic float getTakeoffPositionTolerance()
public Jump<T> setTakeoffPositionTolerance(float takeoffPositionTolerance)
takeoffPositionTolerance - the takeoff position tolerance to setpublic float getTakeoffVelocityTolerance()
public Jump<T> setTakeoffVelocityTolerance(float takeoffVelocityTolerance)
takeoffVelocityTolerance - the takeoff velocity tolerance to setpublic Jump<T> setTakeoffTolerance(float takeoffTolerance)
takeoffTolerance - the takeoff tolerance for both position and velocitypublic Jump<T> setOwner(Steerable<T> owner)
SteeringBehaviorsetOwner in class MatchVelocity<T extends com.badlogic.gdx.math.Vector<T>>public Jump<T> setEnabled(boolean enabled)
SteeringBehaviorsetEnabled in class MatchVelocity<T extends com.badlogic.gdx.math.Vector<T>>public Jump<T> setLimiter(Limiter limiter)
setLimiter in class MatchVelocity<T extends com.badlogic.gdx.math.Vector<T>>public Jump<T> setTarget(Steerable<T> target)
MatchVelocity. Usually
with Jump you should never call it because a specialized internal target has already been created implicitly.setTarget in class MatchVelocity<T extends com.badlogic.gdx.math.Vector<T>>target - the target to setpublic Jump<T> setTimeToTarget(float timeToTarget)
MatchVelocitysetTimeToTarget in class MatchVelocity<T extends com.badlogic.gdx.math.Vector<T>>timeToTarget - the time to set