JayJay

Using PathFinding as a Behavior

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.