Example usage for com.badlogic.gdx.ai.steer.behaviors FollowPath setArrivalTolerance

List of usage examples for com.badlogic.gdx.ai.steer.behaviors FollowPath setArrivalTolerance

Introduction

In this page you can find the example usage for com.badlogic.gdx.ai.steer.behaviors FollowPath setArrivalTolerance.

Prototype

@Override
    public FollowPath<T, P> setArrivalTolerance(float arrivalTolerance) 

Source Link

Usage

From source file:toniarts.openkeeper.world.creature.CreatureControl.java

License:Open Source License

public void navigateToRandomPoint() {
    Point p = worldState.findRandomAccessibleTile(
            worldState.getTileCoordinates(getSpatial().getWorldTranslation()), 10, creature);
    if (p != null) {
        GraphPath<TileData> outPath = worldState
                .findPath(worldState.getTileCoordinates(getSpatial().getWorldTranslation()), p, creature);

        if (outPath != null && outPath.getCount() > 1) {

            // Debug
            //                worldHandler.drawPath(new LinePath<>(pathToArray(outPath)));
            PrioritySteering<Vector2> prioritySteering = new PrioritySteering(this, 0.0001f);
            FollowPath<Vector2, LinePathParam> followPath = new FollowPath(this,
                    new LinePath<>(pathToArray(outPath), true), 2);
            followPath.setDecelerationRadius(1f);
            followPath.setArrivalTolerance(0.2f);
            prioritySteering.add(followPath);

            prioritySteering.setEnabled(!isAnimationPlaying());
            setSteeringBehavior(prioritySteering);
        }//from  w w w  .  ja  v  a2  s. c o  m
    }
}

From source file:toniarts.openkeeper.world.creature.CreatureControl.java

License:Open Source License

public void navigateToAssignedTask() {

    Vector2f loc = assignedTask.getTarget(this);
    if (loc != null) {
        GraphPath<TileData> outPath = worldState.findPath(
                worldState.getTileCoordinates(getSpatial().getWorldTranslation()),
                new Point((int) Math.floor(loc.x), (int) Math.floor(loc.y)), creature);

        if (outPath != null && outPath.getCount() > 1) {

            // Debug
            //                worldHandler.drawPath(new LinePath<>(pathToArray(outPath)));
            PrioritySteering<Vector2> prioritySteering = new PrioritySteering(this, 0.0001f);
            FollowPath<Vector2, LinePathParam> followPath = new FollowPath(this,
                    new LinePath<>(pathToArray(outPath), true), 2);
            followPath.setDecelerationRadius(1f);
            followPath.setArrivalTolerance(0.2f);
            prioritySteering.add(followPath);

            prioritySteering.setEnabled(!isAnimationPlaying());
            setSteeringBehavior(prioritySteering);
        }//www .ja  va 2 s . co m
    }
}