2

I'm working on a Point and Click adventure game in JavaScript and I need help with the whole movement mechanic.

From what I gathered about the subject there seem to be two main subjects- Navigational Meshes and A* Pathfinding Algorithm. However, for the life of me I couldn't find a JS implementation of those combined.

All the A* implementations I've found are grid-based.

What I'm looking for, basically, is a way to navigate inside a large polygon.

I hope I made some sense, I'm not sure I understood it completely myself.

Avada Kedavra
  • 8,523
  • 5
  • 32
  • 48

1 Answers1

0

A* does work on a grid. Really a node-path.

If there's only one node, then A* isn't really going to help a lot, because there's only one node.

You're either going to have to break your large polygon into smaller polygons, for proper node-traversing, or just do something simple like move your character until their feet meet where you clicked (and keep the polygon a REALLY simple square, without anything in the way).

Basically, if you want to do path-finding around objects, then you're going to need to break your path into nodes, somehow.
Whether that's done by subdividing your area into smaller squares, or it's done by doing something like casting rays toward your target, and creating new rays in different directions during collisions (recursively fixing the path as you go -- did I mention that this is a bad idea?)...

Norguard
  • 26,167
  • 5
  • 41
  • 49