Skip to content

[Help] - Add examples to repo #1

@peterchappy

Description

@peterchappy

I'm trying to integrate this library with navmesh and I seem to be getting tripped up on something obvious. Would you be able to include the code for the example Squares at random positions as it's similar to what I'm trying to do.

In making a tower defense with mazing I'm taking the bounds of the towers, and passing them in as the obstacles.

    const obstacles = this.towers.map((t) => t.bounds);

    this.clearDebugPolygon();

    const navMeshPolygons = this.navMeshGenerator.buildNavMesh(
      obstacles,
      obstacleCellPadding,
    );
    
    this.navMesh = new NavMesh(navMeshPolygons);

    const foundMainPath = this.navMesh.findPath(
      { x: 0, y: 300 },
      {
        x: 700,
        y: 300,
      },
    );

So an example of obstacles

[
  {
    "x": 291,
    "y": 283
  },
  {
    "x": 331,
    "y": 283
  },
  {
    "x": 331,
    "y": 323
  },
  {
    "x": 291,
    "y": 323
  }
]

and the returned foundMainPath of

[{ x: 0, y: 300 }, { x: 700, y: 300 }]

Not asking for help debugging, more asking if you could include the linked examples in the repo for me to compare against.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions