Jump to content

Using PathFinding as a Behavior


JayJay
 Share

Recommended Posts

I'm considering using Behaviors (Phaser.Plugin.Behavior) for my game, so I'm trying to understand if player movement could/should be modeled as a behavior, even if entity movement is accomplished via pathfinding (say EasyStar.js). There's no physics, btw.

So the basic idea is to use the the behavior's onUpdate method to do one of 3 things:

1) If path is not yet calculated, it will call the .calculate() method of EasyStar to advance the calculation processing

2) If the calculation is done, move the entity futher along the  path, if not yet reached the target point

3) do nothing (or maybe remove the behavior?) if already arrived at target location.

Let me know if this looks like it could work or otherwise how Phaser.Plugin.Behavior and PathFinding could co-exist on a game.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...