Jump to content

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...