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

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

Introduction

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

Prototype

@Override
    public FollowPath<T, P> setDecelerationRadius(float decelerationRadius) 

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);
        }//www . j  av a 2s. 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  . j  a  va2  s  . c  o m*/
    }
}