Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9090229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:19:37+00:00 2026-06-16T22:19:37+00:00

I have a pathfinding script in JavaScript for HTML5 canvas that appears to have

  • 0

I have a pathfinding script in JavaScript for HTML5 canvas that appears to have an issue with multiplexing.

jsFiddle Demo

The script has been taken and slightly adapted from the accepted SO answer here: A* Start path finding in HTML5 Canvas (which also has the same bug).

How to replicate the issue: Simply click quickly around the map while the red square is in motion, and you will see what appears to be the square splitting or branching off into each of the different paths.

I think what is happening is, as you should notice that the red squares start flickering during branching, it’s actually just the same square trying to be in multiple places at the same time, causing the same square to “teleport” back and forth with the frame rate in alternating frames. This is just a theory though, but I don’t think it’s actually spawning more squares.

I’m not sure if it has to do with the movePlayer() function or the pathFinding() function. I think what I need to do is, if the object is moving and the target tile is updated, cancel any previous operation(s) instead of continuing to run them simultaneously – I have no idea how I would do this though.

As this will eventually be an enemy AI script, the target tile will always be updating in real-time as the player moves around the map, which will likely cause this issue to surface.

Thanks, and I appreciate any help in debugging this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:19:38+00:00Added an answer on June 16, 2026 at 10:19 pm

    From what I can tell, the problem is with the timers being used. When you click, it’s calculating the path between the current location and where you click, then it starts a timer that causes the square to move along that path, storing the information locally for that timer. When you click again, it starts another timer without clearing the old one, so it is now moving along two paths simultaneously from two different timers. It’s drawing out every movement in each timer, and this can be seen as the flickering.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a A* pathfinding script in a simple JavaScript 2D (canvas) game. I
I have a tail recursive pathfinding algorithm that I've implemented in JavaScript and would
This question has been answered. The problem was that myEventMoveTrainManaul() was being called from
I currently have a graph that has about 10 million nodes and 35 million
I seem to have a error in the following A* pathfinding implementation, which I
Have an issue with marshall and unmarshall readers and writers. So here it is.
Have got a method which returns IEnumerable<User> which I have been using Linq /
I have been tasked with creating an interactive 2D map application for a set
Have a photography site that I want to prevent image copying from. How can
Let's say I have a 2d grid. Pathfinding is a secondary step in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.