Skip to content

Latest commit

 

History

History
42 lines (26 loc) · 1.31 KB

path_finding.md

File metadata and controls

42 lines (26 loc) · 1.31 KB

PathFinding

Algorithm to find your way around obstacles

Bonfire uses the package a_star_algorithm to find the path.

To uses just add the Mixin MoveToPositionAlongThePath(by default Player uses) and call the method moveToPositionAlongThePath (never use this method in update method. just one time to start). To this work, the component must contain the Mixin Movement (by defauld Player and Enemy uses).

When you use the JoystickMoveToPosition joystick this functionality is activated in the Player. See here.

Configuring

You can configure PathFinding calling the method setupMoveToPositionAlongThePath. See below:

class Kinght extends SimplePlayer {

    Kinght(Vector2 position)
    : super(
        ...
    ), //required
    ){

        setupMoveToPositionAlongThePath(
            pathLineColor: Colors.lightBlueAccent.withOpacity(0.5),
            barriersCalculatedColor: Colors.blue.withOpacity(0.5),
            pathLineStrokeWidth: 4,
            showBarriersCalculated: false, // uses this to debug. This enable show in the map the tiles considered collision by algorithm.
            tileSizeIsSizeCollision: false,
        )
        
    }
}