Jerenaux / pathfinding_tutorial

Demo for a tutorial showing how to perform pathfinding and move a sprite accordingly with Phaser 3
MIT License
27 stars 21 forks source link

Performance #1

Open Maeggi opened 6 years ago

Maeggi commented 6 years ago

Hello, if you click the mouse more often, the character lags. Have any idea for this problem?

And Thanks for the nice Tutorials

Jerenaux commented 6 years ago

If I correctly see what you mean, then it's not lag, but the fact that when you re-click, the current timeline is stopped and a new one is started. Since the targets of the tweens of the timeline are tiles and not pixels, if the character is in-between two tiles it will move erratically before finding a tile and then proceeding with the timeline. I don't know if I'm clear. :) I'll try to add a fix for that in the future.

Maeggi commented 6 years ago

okay, i understand... can u help me to implement pathfinding in this (pixel to pixel)

http://labs.phaser.io/view.html?src=src%5Cgame%20objects%5Ctilemap%5Ccollision%5Ccsv%20map%20arcade%20physics.js&v=beta18

thank you for your answer and sry for my english :)

Jerenaux commented 6 years ago

The idea there would be similar: you need to have one 2D array where each cell correspond to a pixel of the map, and find a way to indicate which one are walkable or not. Then the rest of the approach is exactly the same. :)