RafaelBarbosatec / bonfire

(RPG maker) Create RPG-style or similar games more simply with Flame.
https://bonfire-engine.github.io
MIT License
1.18k stars 177 forks source link

[Bug]: PathFinding freezes or the character does not move #512

Open nyuntaka opened 1 month ago

nyuntaka commented 1 month ago

What happened?

When creating a slightly complex map, PathFinding freezes or the character does not move.

Freeze example: https://github.com/RafaelBarbosatec/bonfire/assets/14065274/e8e4b9aa-262e-4896-a62a-d48d8d37d9b7

Example of not moving: https://github.com/RafaelBarbosatec/bonfire/assets/14065274/10b2d269-12d1-4d81-8226-e9713e51f095

Steps to reproduce?

class HumanPathFinding extends HumanPlayer with PathFinding, TapGesture {
  HumanPathFinding({required Vector2 position}) : super(position: position) {
    // setupPathFinding(pathLineStrokeWidth: 2);
    setupPathFinding(
      // linePathEnabled: true,
      // pathLineColor: Colors.lightBlueAccent.withOpacity(0.5),
      // barriersCalculatedColor: Colors.blue.withOpacity(0.5),
      // pathLineStrokeWidth: 4,
      showBarriersCalculated:
          true, // uses this to debug. This enable show in the map the tiles considered collision by algorithm.
      useOnlyVisibleBarriers: false,

      // If `false` the algorithm use map tile size with base of the grid. if true this use collision size of the component.
      gridSizeIsCollisionSize: true,
      // factorInflateFindArea: 2,
    );
  }

  @override
  void onTap() {}

  @override
  void onTapDownScreen(GestureEvent event) {
    // moveToPositionWithPathFinding(event.worldPosition);
    var path = getPathToPosition(event.worldPosition);
    debugPrint("240507 path=$path");
    moveAlongThePath(path);
    super.onTapDownScreen(event);
  }
}

What did you expect to happen?

I don't want it to freeze. If there is nothing blocking it, please move correctly.

Bonfire version

3.8.5

Relevant log output

When freezing: No response

When not moving:
240507 path=[[56,56], [56,120]]
240507 path=[[56,120], [104,120], [104,152], [88,152]]
240507 path=[[88,152], [72,152]]
240507 path=[]
240507 path=[]
240507 path=[]
240507 path=[]
RafaelBarbosatec commented 1 month ago

Hi @nyuntaka ! I will analyze this vídeos and try reproduce then. It seems a stress test ☺️. Maybe some problem in create the matrix of possible collision.

nyuntaka commented 1 month ago

I look forward to resolving this issue. Thank you.